Correct me if I'm wrong but I don't believe there is a way to directly access the Microsoft Access database with LC.
Tom
Microsoft Access Database
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Microsoft Access Database
Hi Tom,
No, not directly. You need to use an ODBC driver via DSN or use a DSNless string. I use it all the time but prefer the DSNless string option because one does not have to setup the DSN on each machine.
Tim
No, not directly. You need to use an ODBC driver via DSN or use a DSNless string. I use it all the time but prefer the DSNless string option because one does not have to setup the DSN on each machine.
Tim
Re: Microsoft Access Database
Hi Tim,
Can you show me an example?
Can you show me an example?
Re: Microsoft Access Database
Yes, of course. This is way oversimplified but you'll get the idea. Assuming your developing on and for Windows...
However, keep in mind you don't want to hardcode all your values like this and you'll also want to make sure you include error checking. There are examples and good explanations in the LC dictionary. The majority of the time I use revOpenDatabase, revCloseDatabase, revQueryDatabase, revDataFromQuery, and revDatabaseColumnNamed commands/functions but there are several others that might be useful to you as well.
Code: Select all
local tDatasource
put "Driver={Microsoft Access Driver (*.mdb, *.accdb)};" & \
"DBQ=c:\your\path\to\your\database.accdb;" into tDatasource
local tUsername
put "Admin" into tUsername
local tPassword
put empty into tPassword
local tDatabaseID
put revOpenDatabase("odbc", tDatasource, tUsername, tPassword,) into tDatabaseID
Re: Microsoft Access Database
If you want to develop for Mac as well, I think you need to install an ODBC driver for MS Access like this one:
https://actualtech.com/product_access.php, which in theory should allow you to use the same code cross-platform but not sure what licensing costs/requirements you'd have if actually distributing an app.
https://actualtech.com/product_access.php, which in theory should allow you to use the same code cross-platform but not sure what licensing costs/requirements you'd have if actually distributing an app.