I can open my database with: OpenDatabaseRequester()
But not with: OpenDatabase(0,"WTF should I write here?","","")
It's a mdb database I made with Access and it's stored in the program path...
How to open database?
- Joakim Christiansen
- Addict
- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
How to open database?
I like logic, hence I dislike humans but love computers.
To connect to a database you need an existing ODBC Connection to your database.
Rings (I thought it was rings, sorry if not!) posted two small procedures here to create an ODBC connection within your code.
For eg this creates an ODBC connection:
result=MakeConnection("Microsoft Access Driver (*.mdb)","Server=Your Server Name hier; Description=some text here;DSN=YourDatabaseName;DBQ=c:\accessdatabase.mdb;UID=;PWD=;")
If everything goes right you can now use OpenDatabase(0,"YourDatabaseName").
Mike
Rings (I thought it was rings, sorry if not!) posted two small procedures here to create an ODBC connection within your code.
Code: Select all
#ODBC_ADD_DSN = 1 ; Add Data source
#ODBC_CONFIG_DSN = 2 ; Configure (edit) Data source
#ODBC_REMOVE_DSN = 3 ; Remove Data source
Procedure MakeConnection(Driver.s,strAttributes.s)
result=OpenLibrary(1,"ODBCCP32.DLL")
If result
lpszDriver.s=Driver
; MessageRequester("Info",strAttributes,0)
*MyMemory=AllocateMemory(Len(strAttributes))
CopyMemory(@strAttributes,*MyMemory,Len(strAttributes))
For l=1 To Len(strAttributes )
If PeekB(*MyMemory +l-1)=Asc(";")
PokeB(*MyMemory +l-1,0)
EndIf
Next l
result = CallFunction(1, "SQLConfigDataSource", 0,#ODBC_ADD_DSN,lpszDriver.s,*MyMemory )
FreeMemory(*MyMemory)
CloseLibrary(1)
If result
ProcedureReturn 1
EndIf
EndIf
EndProcedure
Procedure DeleteConnection(Driver.s,DSN.s)
result=OpenLibrary(1,"ODBCCP32.DLL")
If result
lpszDriver.s=Driver
strAttributes.s = "DSN="+DSN
result = CallFunction(1, "SQLConfigDataSource", 0,#ODBC_REMOVE_DSN,lpszDriver.s,strAttributes )
CloseLibrary(1)
If result
ProcedureReturn 1;MessageRequester("Info","DSN Delete",0)
EndIf
EndIf
EndProcedure
result=MakeConnection("Microsoft Access Driver (*.mdb)","Server=Your Server Name hier; Description=some text here;DSN=YourDatabaseName;DBQ=c:\accessdatabase.mdb;UID=;PWD=;")
If everything goes right you can now use OpenDatabase(0,"YourDatabaseName").
Mike
Tranquil
Re: How to open database?
You can try downloading the MDB_Lib from http://www.pureproject.net (ASM lib section)Joakim Christiansen wrote:I can open my database with: OpenDatabaseRequester()
But not with: OpenDatabase(0,"WTF should I write here?","","")
It's a mdb database I made with Access and it's stored in the program path...
It makes creating and connecting to MDB and mySQL databases a breeze and the sample code will get you started very quickly.

- Joakim Christiansen
- Addict
- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
Hi there
Look at Paul Example on the following thread - very useful
viewtopic.php?t=13831
Kind Regardss
Look at Paul Example on the following thread - very useful

viewtopic.php?t=13831
Kind Regardss