Page 1 of 1

Posted: Wed Apr 25, 2007 10:29 pm
by netmaestro

Code: Select all

Declare AddConnection(Driver.s,ConnectString.s) 
Declare RemoveConnection(Driver.s,DSN.s) 

#ODBC_ADD_DSN    = 1    
#ODBC_CONFIG_DSN = 2 
#ODBC_REMOVE_DSN = 3 

;Replace File$ with a database that exists on your system! 
File$ = "d:\wordconnect\twl98.mdb" 
Result=AddConnection("Microsoft Access Driver (*.mdb)","Server=127.0.0.1; Description=MyDescription ;DSN=MyDSN;DBQ="+File$+";UID=;PWD=;") 

If Result 
  InitDatabase() 
  db = OpenDatabase(0, "MyDSN", "", "") 
  If db 
    Debug "Opened Successfully" 
    CloseDatabase(0) 
    If RemoveConnection("Microsoft Access Driver (*.mdb)","MyDSN") 
      Debug "Closed Successfully" 
    EndIf 
  EndIf 
EndIf 

Procedure AddConnection(Driver.s,ConnectString.s) 
    Result=SQLConfigDataSource_(0,#ODBC_ADD_DSN,Driver,ConnectString ) 
    If Result 
      ProcedureReturn 1 
    EndIf 
EndProcedure 

Procedure RemoveConnection(Driver.s,DSN.s) 
    Result=SQLConfigDataSource_(0,#ODBC_REMOVE_DSN,Driver,"DSN="+DSN) 
    If Result 
      ProcedureReturn 1 
    EndIf 
EndProcedure 

Posted: Wed Apr 25, 2007 11:02 pm
by Rook Zimbabwe
NetMaestro... You and Srod and Trond and a great many others are REALLY doing more than a fair share of the helping out around here. I hope I can be as helpful to twinkiebrains like me one day!!!!!!!

8)

Posted: Fri Jun 15, 2007 6:30 pm
by GeoTrail
Thanks for that netmaestro.
Very helpfull :)