Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Create an SQL Server DSN qconfigdata
ddExtender("wwodb34i.dll") :create_datasource c_msgtitle = "ODBC Utility" c_datasource = "sample2" ;Create DSN request=1;ODBC_ADD_DSN driver="SQL Server";case sensitive ;attrs="DSN=TestDB|DESCRIPTION=Testing purposes|Driver=c:\winnt\system32\sqlsrv32.dll|LastUser=helpdesk|Server=%servername%|";pipe delimited ;attrs="DSN=TestDB|DESCRIPTION=Testing|Driver=C:\WINNT\System32\sqlsrv32.dll|LastUser=helpdesk|Server=ictsms01|";pipe delimited ;attrs="DSN=SAMPLE2|DESCRIPTION=Testing|DATABASE=SMS_TEST|DRIVER=C:\WINNT\System32\sqlsrv32.dll|SERVER=ictsms01|LASTUSER=helpdesk|";pipe delimited attrs="DSN=SAMPLE2|DESCRIPTION=Testing|DATABASE=SMS_TEST|DRIVER=C:\WINNT\System32\sqlsrv32.dll|LASTUSER=helpdesk|";pipe delimited displayflag=@TRUE ret=qConfigData(request, driver, attrs, displayflag) test = qConfigError() ;"Driver's ConfigDSN, ConfigDriver, or ConfigTranslator failed"
In general, you should be able to locate the necessary attribute keyword value pairs from the registry. First, manually create the user DSN from the ODBC administrator. Open Regedit.exe and locate the key [HKEY_CURRENT_USER\SOFTWARE\ODBC\ODBC.INI\YourDSNNameHere] these are the entries you will want to use in your Attributes parameter.
Also here is a link to the SQL Server documentation, for the connection
strings....
http://msdn.microsoft.com/library/psdk/sql/od_odbc_c_99yd.htm
attrs="DSN=TESTING|DATABASE=SMS_ICT|SERVER=ICTSMS01|DESCRIPTION=TEST"
Here is the entire working code:
;Create DSN DSNName = "SAMPLE" database = "SMS_TEST" servername = "ictsms01" DSNDesc = "" request=1;ODBC_ADD_DSN driver="SQL Server";case sensitive attrs="DSN=%DSNName%|DATABASE=%database%|SERVER=%servername%|DESCRIPTION=%DSNDesc%";pipe delimited displayflag=@FALSE ret=qConfigData(request, driver, attrs, displayflag)
Article ID: W14778
File Created: 2001:11:08:12:39:58
Last Updated: 2001:11:08:12:39:58