You can connect to MySql through ADO or directly with FWH inbuilt MySql library.
You propose to connect and work using ADO.
For this, you need to download and install MySql ODBC connector on every PC using your software. We assume you have installed the ODBC connector.
We advise you not to make your own connection strings for any server, be it MySql, MSSql, Oracle, etc. If you prepare your own connection strings you need to know the version of ODBC driver or OLEDB provider. When we provide software to several clients they may have already installed different versions of ODBC drivers/OLEDB providers.
Instead use FWH built-in ADO functions.
- Code: Select all Expand view RUN
oCn := FW_OpenAdoConnection( { "MYSQL", cServer, cDatabase/InitialCatalog, cUser, cPassword }, .t. )
if oCn == nil
? "fail"
else
? "connected"
// do your work
oCn:Close()
endif
You can use the same function for MSSQL, Oracle, etc by changing "MYSQL" to "MSSQL" or "ORACLE".
This function checks the version of ODBC driver/OLEDB provider installed on the target PC and uses the latest version installed.
In other words, your program will work on a PC with ODBC 5.1 installed or ODBC 8.0 installed.
All the FWH ADO functions support DBASE, FOXPRO, ACCESS, MSSQL, MYSQL, ORACLE.
They work with any other OLEDB provider if the programmer provides connection string.
Using FWH ADO functions greatly simplifies your work.
For all functions please see fwh\source\function\adofuncs.prg
For working with MySql, you may also consider using the inbuilt MySql library of FWH. For using this, you need not get the ODBC connectors installed on all your clients' PCs. You simply provide your exe with libmysql.dll (provided by FWH ).