Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to add a new DSN programmatically

Tips -N- Tricks

How to add a new DSN programmatically

by  moshi  Posted    (Edited  )
Write the following code in VFP :

LOCAL lcDriver,lc_dsn,fResult
# Define ODBC_ADD_DSN 1

Declare INTEGER SQLConfigDataSource IN odbccp32.dll;
INTEGER ,;
SHORT ,;
STRING @,;
STRING @
Lc_Driver = "driver name" +CHR(0)

lc_dsn = "dsn=MyFirstDsn"+CHR(0)+;
"Server=server name"+CHR(0)+;
"database=Database name"+CHR(0)+;
"Network=DBMSSOCN"+CHR(0)

fResult = SQLConfigDataSource( 0,ODBC_ADD_DSN,@lc_driver,@lc_dsn)

Hope this will add a DSN named MyFirstDsn
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top