lunedì 28 novembre 2011

Problem with COSBI OpenSource Mark

If the workload does not work, it's usually a problem related to the fact that COSBI cannot write the .ini file.

The problem is associated to missing drivers. Install all the drivers needed, and all will work fine :)

sabato 26 novembre 2011

Repair SQL Server Database marked as Suspect or Corrupted

EXEC sp_resetstatus 'real_set_2'
ALTER DATABASE real_set_2 SET EMERGENCY
DBCC CheckDB ('real_set_2')
ALTER DATABASE real_set_2 SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB ('real_set_2', REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE real_set_2 SET MULTI_USER

mercoledì 23 novembre 2011

Windows XP Activation LOOP

To solve the loop, while we are trying to activate, press Windows Key + U, then in the window that pops up press the link to the Microsoft Website, and you will have a nice browser that will fulfill your desires :)

(source: http://www.thetomorrowtimes.com/2006/12/how-to-login-to-expired-windows.html)

mercoledì 2 novembre 2011

(Windows) NTP server for a private network


Need to have a NTP server for your private network?
You have machines that cannot access the Internet, but you need them to be time sync-ed?

I had this problem, and I solved it letting my "gateway" machine (i.e. Controller) become a NTP server.
First of all, activate the Windows Time service in Control Panel -> Administration Tools -> Services.
Then, modify the registry entry using regedit.exe in this way:

System Key: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Parameters]
Value Name: LocalNTP
Data Type: REG_DWORD (DWORD Value)
Value Data: (0 = disabled, 1 = enabled)


Unfortuately, this solution doesn't work (at least for me).
On the other hand, this other solution I found here (http://www.techrepublic.com/blog/datacenter/configure-a-standalone-ntp-server-in-windows-server/3869) works fine ^_^

System Key: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NTPServer]
Value Name: Enable
Value Data: (0 = disabled, 1 = enabled)

Putting the data value to 1 enables the current machine to become a NTP server.
Then, in a command shell update the configuration of the Windows Time service:
> w32tm /config /update

and visualize the new configuration with:
> w32tm /query /configuration

The output should appear like the one in the image



Last step, update the new server machine using a NTP server on the Internet. If you don't do it, you can incurr in some synchronization problem on the clients, like this:
"Error (...) Peer's stratum is less than Host's stratum"
that practically means that the client doesn't trust the new NTP server, as it did not take time from anywhere.
Different thing is if you want to define your machine as a "standalone, trustable NTP server". In that case you need a Knowledge Base from Microsoft that alows to your machine to take the time only from the CMOS clock of your machine.

venerdì 28 ottobre 2011

VirtualBox + Powershell = genius (?) in the box

Today I'm facing another strange behavior of the command-line interface "vboxmanage.exe" for Oracle's VirtualBox.
Here is the Powershell code I'm executing on a remote machine to reboot a virtual machine:
$VM = "WindowsXP";
Invoke-Command -ScriptBlock {vboxmanage controlvm $args reset} -ArgumentList $VM ComputerName 10.3.2.127

Ok, I got an error that is:
VBoxManage.exe: error: Invalid machine state: PoweredOff
+ CategoryInfo : NotSpecified: (VBoxManage.exe:...ate: PoweredOff:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError

VBoxManage.exe: error: Details: code VBOX_E_INVALID_VM_STATE (0x80bb0002), component Console, interface IConsole, callee IUnknown
Context: "Reset()" at line 124 of file VBoxManageControlVM.cpp

The weird thing is that on the machine that hosts the VM (10.3.2.127) the reset works fine.
I checked the execution state on both the host and the remote machine and... guess what... I discovered that the state was different: Powered Off on the remote machine, and running on the host.
host: State: running (since 2011-10-22T22:20:35.359000000)
remote: State: powered off (since 2011-10-18T14:39:32.000000000)
To be sure it was the same machine, I checked the UUID of the machine, and it is the same.
And the machine is accessible, too (it works!)
Another strange thing is the time since the VM results stopped on the remote machine, actually 4 days before, probably since the last try in "reset" the VM.

And here is the deal. When then I tried to start the machine remotely, I got this error:
Invoke-Command -ScriptBlock {vboxmanage startvm "WindowsXP" --type headless} -ArgumentList "WindowsXP" -ComputerName 10.3.2.127
Waiting for VM "WindowsXP" to power on...
VBoxManage.exe: error: Failed to open release log (could not open file 'C:\Documents and Settings\perfmon\VirtualBox VMs\WindowsXP\Logs\VBox.log' (fOpen=0x322), VERR_SHARING_VIOLATION)
+ CategoryInfo : NotSpecified: (VBoxManage.exe:...RING_VIOLATION):String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError

VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component Console, interface IConsole, callee

Then I recalled that the last time I started the VM directly from the host, and not from the remote machine.
Like this, the handler of the log file is still associated to the process which started the machine (on the host), and the powershell process, which tries to access the machine, cannot get the handler. This results in a false information about the state of the machine.

Thus, to solve the problem, I powered off the VM on the host, and I started it successfully on the remote machine:
Invoke-Command -ScriptBlock {vboxmanage startvm "WindowsXP" --type headless} -ArgumentList "WindowsXP" -ComputerName 10.3.2.127
Waiting for VM "WindowsXP" to power on...
VM "WindowsXP" has been successfully started.
and then I checked if the reset was working:
Invoke-Command -ScriptBlock {vboxmanage controlvm $args reset} -ArgumentList "WindowsXP" -ComputerName 10.3.2.127
and the machine state was:
State: running (since 2011-10-28T12:54:58.718000000)

Here we go!!! :)
Ivano 1, VirtualBox 0



giovedì 10 marzo 2011

Microsoft SQL (and other programs) crash due to mscorwks.dll

This kind of crash seems to be provoked in systems where several versions of .NET Framework are installed. About my case, I had .Net Framework 2.0 SP1 and .Net Compact Framework 2.0 SP2 (and also 3.0 and 3.5).

Just uninstalling .Net Compact Framework 2.0 SP2 solved the problem :)

In another case that I had, it was way harder, as I was not able to uninstall or reinstall any of the .Net frameworks. Luckily I found here the solution to my problem (http://blogs.msdn.com/b/astebner/archive/2009/02/18/9432938.aspx). It seems there is a tool coming with the framework that allows to you to repair any damaged file/registry key related to the framework.

Ciao!

mercoledì 9 marzo 2011

Erase the duplicates in a DB table (and "copy" tables!)

What if your table has got some duplicates (because you DO NOT define PRIMARY KEYS...)???

Well, we can select distinct rows from the table, and then create a new table with the resultset.
The syntax that we need is the following:

SELECT DISTINCT * INTO [new_table] FROM [old_table]
In addition, if the table already exist, we can use the INSERT INTO command:

INSERT INTO [new_table]
SELECT * FROM [old_table]

That's all!!! :)
when trying to use psexec.exe on a remote machine, it may happen that the following error may occurr:

Logon failure: unknown user name or bad password.


To solve this problem, just change the value in Local Security Policy -> Security options, change:
  • Network access: Sharing and security model for local account (Classic)
...and that's all!!! :)

mercoledì 23 febbraio 2011

Connect from (Matlab on) MACOSX to Microsoft SQL Server (2005 Express)???

OK, that's a bit malad.
We have two ways: ODBC (proprietary, I downloaded OpenLink ODBC Adminstrator, with 30days trial), easily configurable, or JDBC (needed if you're using, for instance, Matlab for MacOS/Linux).
About JDBC, this link (http://www.razorsql.com/articles/sql_server_mac.html) says that we can have the JDBC driver in two ways:
The easiest way to connect to MS SQL Server from Mac is with a JDBC (Java Database Connectivity) driver. Since Mac OS X comes with Java pre-installed, the only thing that needs to be downloaded is a suitable JDBC driver. There are two options for JDBC driver. Once is the open source jTDS driver. The other is the JDBC driver from Microsoft.
About the JDBC driver from Microsoft, I'm not able to understand how to install it... and to use it...
About the iTDS driver, I downloaded it, but it comes like the Microsoft driver: basically a .jar file.

What to do?

I found it! ;)
JDBC is not like ODBC connection. ODBC is Microsoft-proprietary, and need some "tool" (like the one from OpenLink) to interact with the OS. JDBC, on the contrary, needs only an application to call the jar file, and so the libraries in it.

My problem was to connect to a Microsoft SQL Server 2005 with Matlab for MacOSX.
Matlab come with the Database Toolbox, and reading the help (...carefully reading...), I learned something. Matlab can use ODBC on Windows systems, and ODBC/JDBC on other systems. So, as we are in MacOSX, we are going to use a JDBC, previously downloaded (done!).
Now, guess wath? As Matlab is an application, and it's developed in Java too (and comes with his Java VM!!!), it's only necessary to understand where to indicate to Matlab the path of the JDBC jar-file.

I found this:
Specify the location of the drivers file in the MATLAB Sun Java classpath by adding this file's path to the matlabroot/toolbox/local/classpath.txt file.

I found it in /Applications/MATLAB_R2009b.app/toolbox/local/ , and I add the path "/Users/ivanoirrera/lib/MSSQL_JDBC/sqljdbc.jar" (in my case, but you can put the jar-library everywhere you want). Then restart Matlab.
After it, run "querybuilder", and click Query > Define JDBC Data Source.

Now, specify correctly the information the connection needs.
In my case:

name = master
driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
URL = //10.3.1.200:1433/master

Note: the Java version used by Matlab is 1.6, and Microsoft JDBC drivers 2.0 do not support this version! To solve the problem, download the "Microsoft SQL Server 2005 JDBC Driver 1.2" version.

Anyway... now it shows no problem... but it blocks :(

(to be completed)

martedì 22 febbraio 2011

Cannot start the Perfmon service

The Perfmon service (with 387 variables) cannot start, due to this problem:

Event Type: Error
Event Source: PDH
Event Category: None
Event ID: 3041
Date: 25-12-2010
Time: 20:43:29
User: N/A
Computer: TARGETREAL
Description:
The description for Event ID ( 3041 ) in Source ( PDH ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user ''. The user is not associated with a trusted SQL Server connection..
Data:
0000: 14 .

To solve this problem, modify the registry on Controller (and Target?) systems.
Open Control Panel -> Administration tools -> Local Security Policy -> User Righ Assignment, and change the voices:
  • Access computer from the net (Everyone)
  • Deny access to this computer (erase Guest, if exists)
  • Enable computer and user accounts to access... (Everyone)
  • Enable computers and user to be trusted for delegation (Everyone, Guest, ...)

Moreover, in Local Security Policy -> Security options, change:

  • Network access: Sharing and security model for local account (Classic)

Then, you may have this problem:

Event Type: Error
Event Source: PDH
Event Category: None
Event ID: 3041
Date: 22-02-2011
Time: 21:04:59
User: N/A
Computer: TARGETREAL
Description:
The description for Event ID ( 3041 ) in Source ( PDH ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'LAB\Guest'..
Data:
0000: 18 .


To solve this problem, you must add the user GUEST in SQL Server (under the folder Security -> Logins).
Give to him the sysadmin right, or less.

venerdì 11 febbraio 2011

Install Windows XP on a Asus P5S800-VM motherboard

It's only necessary to enter the Bios, and in the first table change the "SATA" setting to "Normal".
Then the motherboard will emulate the SATA disk as PATA.
That's all :)

martedì 8 febbraio 2011

Restoring Windows XP backup + Microsoft SQL Server (Express) 2005

When restoring this backup on a pre-existing Windows XP machine, a malfunctioning in the Microsoft SQL Server 2005 occurred.
These are the problems that I encountered.

1) When trying to connect to the DB ("Microsoft SQL Server Management Studio Express"), this error occurs:

TITLE: Connect to Server
------------------------------

Cannot connect to PCG5116\SQLEXPRESS.

------------------------------
ADDITIONAL INFORMATION:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (Microsoft SQL Server, Error: -1)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=-1&LinkId=20476


2) On the other hand, if I try to open "SQL Server Configuration Manager", I get this error:

Cannot connect to WMI provider. You do not have permission or the server is unreachable. Note that you can only manage SQL Server 2005 servers with SQL Server Configuration Manager.
Invalid class [0x80041010]

3) I also tried to access the DB configuration from the "SQL Server 2005 Surface Area Configuration", clicking on one of the two possible choices to chow the configuration, and what I got was:

TITLE: Surface Area Configuration
------------------------------

Computer localhost does not exist on the network, or the computer cannot be configured remotely. Verify that the remote computer has the required Windows Management Instrumentation components and then try again. (SQLSAC)

------------------------------
ADDITIONAL INFORMATION:

An exception occurred in SMO while trying to manage a service. (Microsoft.SqlServer.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.1399.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.InnerWmiException&LinkId=20476

------------------------------

Failed to retrieve data for this request. (Microsoft.SqlServer.SmoEnum)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&LinkId=20476

------------------------------

Invalid class (System.Management)

------------------------------


In addition, going in Windows Event Viewer (Control Panel), for every attempt to access the DB or its configuration, I got this error entry:
Event Type: Error
Event Source: MSSQL$SQLEXPRESS
Event Category: (2)
Event ID: 17058
Date: 10-12-2010
Time: 18:29:35
User: N/A
Computer: PCG5116
Description:
initerrlog: Could not open error log file 'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG\ERRORLOG'. Operating system error = 5(Access is denied.).

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Data:
0000: a2 42 00 00 10 00 00 00 ¢B......
0008: 13 00 00 00 50 00 43 00 ....P.C.
0010: 47 00 35 00 31 00 31 00 G.5.1.1.
0018: 36 00 5c 00 53 00 51 00 6.\.S.Q.
0020: 4c 00 45 00 58 00 50 00 L.E.X.P.
0028: 52 00 45 00 53 00 53 00 R.E.S.S.
0030: 00 00 00 00 00 00 ......

It then seems that there is some problem with the access rights on the SQL Server (its services and files)
Then I noticed that the SQL Server service (SQLExpress) is stopped (in Control Panel -> Administrative Tools -> Services). It cannot start because:
Windows could not start the SQL Server (SQLEXPRESS) on Local Computer. For more information, review the System Event Log. If this is a non-Microsoft service, contact the vendor, and refer to service-specific error code 17058.
In the same window, in Log On tab I noticed that there the configuration "Log on as: This account -> AUTHORITY\NetworkService".


SOLUTION: If changing to Log on as: Local System Account, the service starts without any problem. And anyone can access from the net the SQL Server too!!! :)

Part of the solution (probably): restore the WMI repository, with this script

net stop winmgmt /Y
c:
cd %systemroot%\system32\wbem
rd /S /Q repository


regsvr32 /s %systemroot%\system32\scecli.dll
regsvr32 /s %systemroot%\system32\userenv.dll


mofcomp cimwin32.mof
mofcomp cimwin32.mfl
mofcomp rsop.mof
mofcomp rsop.mfl
for /f %%s in ('dir /b /s *.dll') do regsvr32 /s %%s
for /f %%s in ('dir /b *.mof') do mofcomp %%s
for /f %%s in ('dir /b *.mfl') do mofcomp %%s
echo DONE reboot
pause