Using MySQL with the Database Connectivity Toolkit on Windows
Primary Software: LabVIEW Toolkits>>Database Connectivity Toolset
Primary Software Version: 1.0
Primary Software Fixed Version: N/A
Secondary Software: N/A
Problem: I do not know how to connect to a MySQL database with LabVIEW and the Database Connectivity Toolkit from my Windows machine.
Solution: There are several ways to connect to a MySQL database from LabVIEW using the Database Connectivity Toolkit. This article outlines how to use the ODBC tools provided by
Mysql.com. This article also assumes that you either have a MySQL database installed and running on your current computer or another computer accessible through the network.
- Download the ODBC zipped DLL's from mysql.com. You can do so from this link: http://dev.mysql.com/downloads/connector/odbc/3.51.html
- Extract the files using pkzip or some compatible program - put them in your Program Files directory.
- Go to that directory and register drivers with the system - you can do this by running the INSTALL.BAT file inside the directory, or manually.
- Navigate to Start -> Control Panel -> Administrative Tools -> Data Sources (ODBC), then click the Drivers tab. Ensure MySQL shows up here.
- Go back to the User DSN tab, click Add, and select MySQL.


- A new window will popup allowing you to enter in your connection information to your MySQL server. The default port number is 3306. You can use localhost as the server name if you have it installed on the computer you're currently working on.

- In LabVIEW, put a DB Tools Open Connection VI on the block diagram. Wire a true constant into the prompt input.
- Run the vi - a prompt will come up asking for your connection. Switch over to the Connection tab, and from the drop down Use data source name, select the server connection you've just created.
At this point, your application will error out, but that's because you did not do anything with the connection. In your application, be sure to use a DB Tools Close Connection VI at the end of your program or database access. You can specify the path to your DSN file by creating a control wired to the source terminal on the DB Open Tools VI and setting the prompt value to false.
For further help, see the
Database Connectivity User's Manual.
Related Links:
MySQL Connector ODBC
Product Manuals: LabVIEW Database Connectivity Toolkit Manuals ()
Attachments:
- odbc.jpg
- dsn.jpg
- connector.jpg
Report Date: 10/17/2006
Last Updated: 12/11/2006
Document ID: 42GBLU00