Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can't create DSN on Win2K ?!
Message
From
15/11/2002 15:21:19
 
 
To
15/11/2002 15:01:51
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00723388
Message ID:
00723402
Views:
19
Try adding "Trusted_Connection=No" to the string for SQL authentication. Find out more about the error using AERROR() if there is one. HTH

>Hello...
>
>I am trying to programmatically create a DSN on my Win2K machine. I have searched through the UT, MS Knowledge base, etc. and found several examples and articles on how to do this. However, this doesn't work for me. Thought the return value is a Zero, which indicates a success. If I purposely leave out some part of the DSN string (user id or password, for example) in order to induce an error, the return value is a -1...but the DSN is created, albeit without a proper username or passwrod.
>
>
>Can anyone see what is wrong with my code? I am running VFP7, Win2K and I have made sure the I have the latest MDAC installed as well.
>
>I need to accomplish this with SQL Server Authentication...though I tested with Windows Auth and that doesn't work either.
>
>Here is my Code:
>
>*-----------------------------------------------------*
>*
>* CreateODBC.prg
>*
>*-----------------------------------------------------*
>*-- set up the constants....
>#define ODBC_ADD_DSN 1
>#define ODBC_CONFIG_DSN 2
>#define ODBC_REMOVE_DSN 3
>#define ODBC_ADD_SYS_DSN 4
>#define ODBC_CONFIG_SYS_DSN 5
>#define ODBC_REMOVE_SYS_DSN 6
>#define ODBC_REMOVE_DEFAULT_DSN 7
>#define SQL_NO_DATA 100
>#define SQL_SUCCESS_WITH_INFO 1
>#define SQL_SUCCESS 0
>#define SQL_ERROR -1
>
>**DECLARE Integer SQLConfigDataSource IN odbccp32.dll Integer, Integer, String, String
>
>DECLARE Integer SQLConfigDataSource IN odbccp32.dll Integer, Short, String @, String @
>
>
>*-- initialize return value...
>lnResult = -1
>
>lcDriver = "SQL Server" + CHR(0)
>lcDSN = "dsn=Test_DSN_2" + CHR(0) + ;
> "server=sqltest2" + CHR(0) + ;
> "DATABASE=mrscustomer" + CHR(0) + ;
> "uid=sa" + CHR(0) + ;
> "pwd=myPassword" + CHR(0) + ;
> "network=DBMSSOCN" + CHR(0)
>
>lnResult = SQLConfigDataSource(0, ODBC_ADD_SYS_DSN, @lcDriver, @lcDSN)
>
>* end of program...
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform