Treceți la conținutul principal

Using Visual FoxPro and the ODBC Driver to connect to a MySql Database

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

Postări populare de pe acest blog

Laravel 5 "Hello World" example using Xampp and Composer

This is a tutorial about creating your first project in the Laravel framework and running it with the help of Xampp. This tutorial has been done for Laravel 5 and, since then, some of the framework's files and folders have changed but the process of setting up the project is identical so you can still use it today. Image 1 - Laravel welcome page - image by C.R.G. You can download the project via Git  here . Here 's the youtube link to a similar tutorial. Other links you may want to visit: Laravel docs Xampp download Composer download Notepad++ download Also, you can learn more abour laravel and model-view-controllers on wiki. First, I'll start by explaining what is Laravel.   Laravel is a free and open-source PHP web framework, intended for the development of web  applications following the MVC or Model–View–Controller architectural pattern.  Some of the features of Laravel are a modular packaging system with a dedicated  dependency manager, different

Changing the processor on a LGA775 motherboard

Fig. A First of all, please read the disclaimer at the bottom of this page. You should also know this tutorial is intended for the more popular air coolers that normally contain a fan and a radiator, like shown in the image on the right. Now, with that out of the way, I'd like to explain a few things about the LGA775 motherboard and compliant processors. Unlike older socket types ( Socket 478 for example ), the LGA 775 motherboard introduced protruding pins instead of the multiple socket holes found in the past ( see fig. 1 ). There are 775 pins, hence the name. As expected, the compatible processors don’t have multiple pins on them like older processors, instead having just connectors arranged in the same pattern as the pins on the motherboard ( fig. 2 ). Fig. 2   Fig. 1 What will we need for this task? I hear you ask.. A LGA775 compatible processor ( mine is a 2.9GHz x86 Intel Pentium Dual-Core ); Thermal paste ( I've used MX4 thermal compound - the manufacturing