What you'll need:
1. Ms Visual FoxPro ( any version since 6.x will do but I’ve used 9.0 );
2. XAMPP ( to set up an Apache web server and a MariaDB database server );
3. MySql ODBC Driver ( I’ve used v.5.3 but any version should work );
4. Creating a VFP script that sends MySql commands to the MySql server;
FoxPro by Carlosgutierreztobon17, CC BY-SA 4.0 via Wikimedia Commons |
1. Ms Visual FoxPro
You’ll obviously need to install VFP for this operation. I can supply you with a standalone version of the script but it won't be free as it needs to be custom made for your requirements ( if you still want this check the link at the bottom of this tutorial ).
2. Setting up XAMPP
XAMPP is required if you don’t already have Apache and MySql servers installed. It will contain both of these modules and you won't have to worry about installing and configuring them.
Use this link: https://www.apachefriends.org/download.html
and select the correct version depending of your OS ( Windows / Linux - 32bit / 64bit ).
Once you’ve installed XAMPP proceed by starting XAMPP Control Panel and click the Start buttons corresponding to the Apache ( Fig. 1 – 1 ) and MySql ( Fig. 1 - 2 ) modules.
Fig. 1 |
Open a browser window ( Chrome, Firefox, iE ) type “localhost/phpmyadmin” and hit enter to be redirected to the PhpMyAdmin page ( Fig. 2 ). In there, you can create a new database and tables or use existing ones ( Fig. 2 - 1 ).
Fig. 2 |
3. Installing MySql ODBC driver on Windows
For older Windows OS ( XP or older ):
Click the Start button (or hit the “Windows” button on your keyboard) then go to: Control Panel -> System Administrator -> Data Source ODBC.
For newer Windows OS ( Win 7 or newer ):
Click the Start button (or hit the “Windows” button on your keyboard) and type “Data Sources”. At the top of the list “Data Sources (ODBC)” will probably appear so select it.
The “ODBC Data Source Administrator” dialog will appear
( Fig. 3 ).
In the “User DSN” tab click on the Add button ( Fig. 3 - 1 ).
Fig. 3 |
From the “Create New Data Source” dialog ( Fig. 4 - 1 ) select the MySql driver you want to use. It should be named like so: MySql x.x ODBC Driver ( where x.x stands for your current version – my version is 5.3 ).
Normally, you’ll have 2 drivers: ANSI and Unicode, each corresponding to your server connection. You can check that in PhpMyAdmin main page under “server charset” ( Fig. 2 - 2 ) or “server connection collation” ( Fig. 2 - 3 ).
For me it is a UTF-8 Unicode connection so I’ll select the MySql 5.3 ODBC Unicode Driver.
Fig. 4 |
Click on Finish and you’ll be prompted by the “MySQL Connector/ODBC Data Source Configuration” ( Fig. 5 ) dialog to..well..configure the data source.
In the “Data Source Name” ( Fig. 5 - 1 ) textbox, type the name of the data source ( “tst” for me but this can be anything );
At “TCP/IP Server” ( Fig. 5 - 2 ) type the server’s name ( “localhost” for me );
In the “User” ( Fig. 5 - 3 ) textbox, type the username you use for your MySql server connection ( “root” is default );
In the “Password” field ( Fig. 5 - 4 ) type the server’s password or leave it blank if you don’t have one ( nothing for me as I’m using a test server );
From the “Database” dialog ( Fig. 5 - 5 ), select the database you want to work with ( “test” for me ).
You can click the Test button ( Fig. 5 - 6 ) to test the connection. A dialog will notify you the connection is working well.
Now select OK and you’re good to go.
Fig. 5 |
4. Creating a VFP script that sends MySql commands to the MySql server
To accomplish this task I’ve created a script that can connect to the MySQL server and perform various operations on it ( CRUD if you’re into acronyms 😆 ).
This will be done with the help of a very useful VFP method called “SQLSTRINGCONNECT” that takes all the parameters needed to establish a connection to the server as a string of characters.
Once the connection has been established ( the method will return a positive value in case of success ), you can then call the “SQLEXEC” method to run any MySQL command.
After you are done you need to close the
connection using the “SQLDISCONNECT” method.
If you don’t have experience using Visual FoxPro or don’t know how to use the methods I’ve just described I can create a simple script for you for just $5 or $10 if you need the standalone version.
Contact me via Fiverr.
C.R.G. 2023
Comentarii
Trimiteți un comentariu