PDA

View Full Version : Problems connecting to SQL Server 2005 from Windows 7



redBeard
18th April 2012, 22:52
I have a Qt-based application that communicates with databases. I compiled Qt (4.7.4) statically and built in support for MySQL and ODBC. I connect to MySQL and SQL Server databases in my development environment.

I've been working well for many months and now I'm deploying my application on different systems.

I deploy my statically built executable along with the 'libmysql.dll' library. I can successfully connect to MySQL with this application. When trying to connect to SQL Server (using the ODBC driver), I specify the following as the databaseName (QSqlDatabase.setDatabaseName():

DRIVER={SQL Server};SERVER=%1;DATABASE=%2;UID=%3;PWD=%4

- where %1 is the hostname, %2 is the database name.

SQL Server is running on a Windows Server 2008 SP2 system. SQLServer version is 2005 (9.0.1399).

If I run my program on XP or Vista systems I can successfully connect to that DB. However, if I run my program on a windows 7 32-bit or 64 system, I get the following error from the QSqlDatabase.open() call:

"Specified driver could not be loaded due to system error 126: The specified module could not be found. (SQL Server, %WINDIR%\system32\SQLSRV32.dll). QODBC3: Unable to connect"

I checked and, yes, the SQLSRV32.dll exists in the system32 directory.

I can connect to this database from my Windows 7 64-bit development environment system.

I seem to be missing some bit of configuration or run-time environment foo on that win 7 32-bit system. I'm using VS 2008 for development and installed the VS2008 redistributable on that win7-32 system. Still doesn't work....

Ideas?

redBeard
2nd May 2012, 23:18
The full story is that I'm launching this Qt-based application from a Java program. The Java program needs to specify the entire working environment for the Qt application (as a separate process).

Windows 7 now uses/references the environment variable 'WINDIR' in the registry whereas before it pretty much hard-coded 'c:\windows' everywhere.

I just had to set the 'WINDIR' environment variable in the process that launched the Qt application.

Issue resolve.