Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to create a ODBC DATASOURCE programmatically
Message
 
To
12/11/2001 03:17:00
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00579560
Message ID:
00580420
Views:
23
>Yes! I try your code and it is working, but I need to specify the system table(*.mdw), userid , passward too. How can I do that?
#define ODBC_ADD_DSN 1
#define ODBC_ADD_SYS_DSN 4

Declare Long SQLConfigDataSource In ODBCCP32.DLL ;
Long hwndParent, Long fRequest, String lpszDriver, String lpszAttributes

strDriver = "Microsoft Access Driver (*.mdb)"
strAttributes = "DESCRIPTION=Temp DSN" + Chr(0)
strAttributes = strAttributes + "DSN=DSN_TEMP" + Chr(0)
strAttributes = strAttributes + "DBQ=E:\new.mdb" + Chr(0)
strAttributes = strAttributes + "DriverId=281" + Chr(0)
strAttributes = strAttributes + "FIL=MS Access" + Chr(0)
strAttributes = strAttributes + "MaxBufferSize=2048" + Chr(0)
strAttributes = strAttributes + "PageTimeout=5" + Chr(0)
strAttributes = strAttributes + "SystemDB=E:\Program Files\Microsoft Office\Office\SYSTEM.MDW" + Chr(0)
strAttributes = strAttributes + "UID=Admin" + Chr(0)
strAttributes = strAttributes + "PWD=password" + Chr(0)
intRet = SQLConfigDataSource(0, ODBC_ADD_DSN, @strDriver, @strAttributes)
If intRet = 0
   MessageBox("DSN Create Failed")
EndIf
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform