Archive: trouble creating DSN


trouble creating DSN
hello, i don't know what more should i try, so here is my problem:

i have to make an installer for a application that uses a SQL database. the software is "bundled" with MSDE. i must make the connection to the database. after i searched the forums and the archive i used the following (for the dsn creation) :

StrCpy "$DSNDIR" "path to db"
ReadRegStr $COMPNAME HKLM "System\CurrentControlSet\Control\ComputerName\ComputerName" "ComputerName"
StrCpy $USERNAME "sa"

WriteRegStr HKLM "Software\ODBC\ODBC.INI\dsnname" "Driver" "$SYSDIR\SQLSRV32.dll"
WriteRegStr HKLM "Software\ODBC\ODBC.INI\dsnname" "Server" "$COMPNAME"
WriteRegStr HKLM "Software\ODBC\ODBC.INI\dsnname" "Database" "db"
WriteRegStr HKLM "Software\ODBC\ODBC.INI\dsnname" "AttachDBFileName" "$DSNDIR"
WriteRegStr HKLM "Software\ODBC\ODBC.INI\dsnname" "LastUser" "sa"
WriteRegStr HKLM "Software\ODBC\ODBC.INI\ODBC Data Sources" "dsnname" "SQL Server"


now comes the interesting part.
i try to open the application and it gives me an error - cannot connect to database, login failed.

i go to Data Sources ODBC (in Control Panel) and i make a test for the connection, and the result is : SUCCESFULLY !!!
after this, i open the application and it works !? why ? i do not modify anything with the test. do i must make the test for the connection to work ? how, from NSIS ?

if you understood something from all this, please give me a hand...

Thanks, OJi.

Have you tried the System.dll code brainsucker posted on one of the DSN threads?


i saw that line, but i have no idea how to use that or what to modify in it. i will search on msdn and post my result. thanks.