>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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only