| Subject |
Re: Using dBase to Access Data Stored in MariaDB |
| From |
Mervyn Bick <invalid@invalid.invalid> |
| Date |
Thu, 1 Sep 2022 12:14:44 +0200 |
| Newsgroups |
dbase.getting-started |
On 2022/08/31 19:00, Ketan G wrote:
> Briefly, I need to access data stored in a MariaDB database (several tables) using dBase.
>
> Through a bit of reading and following this forum, have a vague idea that this is done through the BDE (older method) and through ADO (nowadays the more recommended approach).
>
> However, I have no experience of either of these methods as my use of dBase is for local tables, and through xBase commands.
>
> Any suggestions on a good starting point (reading as well as code examples) would be a great help.
>
Reading data from MariaDB tables is not much different to reading data
from .dbf tables. When accessing .dbf tables one can either use the
default database object built into dBASE or include a database object in
a form or datamodule. When using ADO to access a SQL server one always
needs to include an ADOdatabase object. The BDE can be used but you
will be far better served by using ADO.
If you use parameter driven queries the syntax for passing the
parameters to an ADOquery object is slightly different to passing
parameters to a query object which accesses the BDE. If you need to
insert, update or delete data you will need to learn a new technique but
it's not difficult.
You will need the DBA responsible for the care and feeding of the
MariaDB database to register you as a user and give you a password.
You will need to install a 32-bit ODBC driver for MariaDB on your
computer even if you are using 64-bit Windows as dBASE is a 32-bit program.
https://mariadb.com/kb/en/mariadb-connector-odbc/
Note that there are several .pdf files. They are there so that when all
else fails you can read up on "how to". :-)
You will need a Connection String for an ADOdatabase object in your form
or datamodule. I don't use MariaDB so I can't guarantee that any
connection string I give you will actually work. There are, however,
other users here who use MariaDB who will help you if you have trouble
building the string from the information available on the MariaDB website.
As far as fetching data from MariaDB tables go, you need to make the
ADOquery objects read-only i.e set the requestLive property false. Any
SQL command you have used previously with .dbf tables will work. The
only thing that will need to change is the syntax for parameters in a query.
dBASE allows the use of localSQL, which is a subset of "proper" SQL, in
the sql property of a query. Being able to use "proper" SQL opens up a
whole new world. You will be able to craft queries which are simply not
possible in localSQL. The W3Schools SQL tutorial is a good place to
start. Although there as a standard for SQL not all implementations
follow it strictly. Where syntax is given for various database engines
the one given for MySQL should work with MariaDB.
https://www.w3schools.com/sql/
Mervyn.
|
|