Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
15 ratings:
 4.46 out of 5     Rate this Document

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:
How do I connect to a MySQL database using the LabVIEW 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.
  1. Download the ODBC server MSI from mysql.com.
  2. Install the server on your PC
  3. Navigate to Start»Settings»Control Panel»Administrative Tools»Data Sources (ODBC)
  4. Click the Drivers tab and ensure that MySQL is listed
  5. Go back to the User DSN tab, click Add, and select MySQL




  6. 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 enter localhost as the server name if you have it installed on the computer you're currently working on.


  7. In LabVIEW, put a DB Tools Open Connection VI on the block diagram and wire a true constant into the prompt input.
  8. Run the VI
  9. A prompt will come up asking for your connection. In this dialog box select the Connection tab, and from the Use data source name drop down list 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 (June 2008)

Attachments:


odbc.jpg - odbc.jpg
dsn.jpg - dsn.jpgconnector.jpg - connector.jpg


Report Date: 10/17/2006
Last Updated: 07/24/2009
Document ID: 42GBLU00

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit