SQL Config Data Source - a function in odbccp32.dll
I need to create a ODBC-Datasource programmatically. There's one problem. I haven't found out to set uid and pwd.
Here's my code:
DECLARE INTEGER SQLConfigDataSource in odbccp32.DLL ;
INTEGER hwndParent, INTEGER fRequest, ;
STRING @lpszDriver, STRING @lpszAttributes
lcAttributes = "DSN=test" + CHR(0) + ;
"Server=(local)" + CHR(0) + ;
"database=datenbankname" + CHR(0) + ;
"UID=sa;" + ;
#DEFINE ODBC_ADD_SYS_DSN 4
lnReturn = SQLConfigDataSource( 0, 4, "SQL Server" + CHR(0), lcAttributes )
I doesn't work. It works without uid and pwd.
Does anyone know how to include user and password?
UID and PWD are not supported by the API. Actually all that SQL Config Data Source does is make entries in the registry. If you look at HKLM_\Software\OBDC\ODBC.INI you will see that the password for the other DSNs is not saved. When you connect through a DSN you will always be required to present a user ID and password or else use a trusted connection, i.e., "DSN=MyDSN;UID=Smith;PWD=Sesame" or "DSN=MyDSN;Trusted_Connection=yes".
Category Data Category Code Samples
( Topic last updated: 2003.11.22 06:04:15 PM )