Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dynamically creating DSNs through VFP
Message
From
26/08/1999 03:47:46
 
 
To
26/08/1999 02:35:48
Shaheer Shamsi
Boston Education & Software Technologies
Mumbai, India
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00257747
Message ID:
00257761
Views:
14
>I have to create the DSNs manually on every machine to connect to my remote database which is in MS-Access. I want that whenever I install my software the DSN along with the Database name should be created on the machine, because if try to connect through ODBC through sqlconnect() function it asks me a DSN and the database name for the DSN. So I want to Dynamically create a DSN on every machine, can anybody help me out.
>
>Regds...
>Shaheer

Hi Shaheer,

Here's the code I use to do it:




local m_x

declare integer SQLConfigDataSource in odbccp32.dll integer,integer,string,string
tcDSN='YourDSNName'
tcPath='X:\DataDirectory'

lcType='Microsoft Visual FoxPro Driver'
lcODBC='DSN='+alltrim(tcDSN)+chr(0)+;
'Description='+alltrim(tcDSN)+chr(0)+;
'SourceDB='+alltrim(tcPath)+chr(0)+;
'SourceType=DBC'


SQLConfigDataSource(0,3,lcType,lcODBC)
m_x=SQLConfigDataSource(0,1,lcType,lcODBC)

if m_x=0
return .t.
else
return .f.
endif

This example is to create a ODBC DSN to a VFP Data source. To an Access Data source you have to include the proper parameters for the driver you're using.
Previous
Reply
Map
View

Click here to load this message in the networking platform