DB exists but will not open [Exquisitely SOLVED]

Just starting out? Need help? Post your questions and find answers here.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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 
BERESHEIT
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post 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)
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post by GeoTrail »

Thanks for that netmaestro.
Very helpfull :)
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
Post Reply