Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can't create DSN on Win2K ?!
Message
From
18/11/2002 11:30:16
 
 
To
18/11/2002 09:45:34
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00723388
Message ID:
00723883
Views:
21
Thanks again for the help.

I tried your code....replacing server and database with valid values from our sql server and it still does not work. Actually, the first time I did not include the login and password and the value for nResult was a 1, which indicates a problem. I checked and there was a "testdsn" entry in my USER connections tab...but it was not complete. That makes sense because of the lack of sql authenticaiton (I didn't supply the login and password). Once I added "uid=sa" and "pwd=myPassword", the value for nResult was 0 (zero), which indicates Success! However, there weren't any "testdsn" entries in User or System tabs.

I am using MDAC 2.7....I recently installed VS.Net. I wonder if that is the issue?
....Douglas


>I have the same setup and it works fine for me (MDAC 2.6). This is the code I am using:
>
#define ODBC_ADD_DSN 1
>
>DECLARE Integer SQLConfigDataSource IN odbccp32.dll Integer, Short, String @, String @
>
>lc_driver = "SQL Server" + CHR(0)
>lc_dsn = "dsn=testdsn" + CHR(0) + ;
>         "server=myserver" + CHR(0) + ;
>         "database=mydb" + CHR(0) + ;
>         "trusted_connection=No" + CHR(0)
>
>nResult = SQLConfigDataSource(0, ODBC_ADD_DSN, @lc_driver, @lc_dsn)
>? nResult
>Before this I made sure there was no other "testdsn" entry under User or System tabs.
>
>>I just tried that...adding the "Trusted_Connection=No" and still the DSN is not being created. The return value, from SQLConfigDataSource is a Zero, which indicates a success. No errors!?
>>
>>Thanks for trying.
>>...Douglas
>>
>>>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