I don't know why I posted this in beginners the first time!
---
I found this the other day in an app I wrote some months ago. I didn't write it but I can't remember who did! Still, thought I would share..
Creating a DSN for Access on the fly :
Code: Select all
Procedure database_command(command.s)
cmd = AllocateMemory(Len(command))
For tmp=0 To Len(command)-1
asc=PeekB(@command+tmp)
If asc=59
PokeB(cmd+tmp,0)
Else
PokeB(cmd+tmp,asc)
EndIf
Next
If OpenLibrary(9,"ODBCCP32.DLL")
SQLConfigDataSource = GetFunction(9,"SQLConfigDataSource")
Result = CallFunctionFast(SQLConfigDataSource,0,1, @"Microsoft Access Driver (*.mdb)", @cmd)
CloseLibrary(9)
EndIf
FreeMemory(cmd)
ProcedureReturn Result
EndProcedure
Code: Select all
database_command("Server=RMServer;Description=my_db;DSN=my_db;DBQ=c:\my_db.mdb;UID=my_username;PWD=my_password;")