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 (see Remote Access from your webhost)
- Download the ODBC server MSI from mysql.com.
- Install the server on your PC
- Navigate to Start»Settings»Control Panel»Administrative Tools»Data Sources (ODBC)
- Click the Drivers tab and ensure that MySQL is listed
- 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 enter 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 and wire a TRUE constant into the prompt input.
- Run the VI
- A prompt will come up titled Data Link Properties. On the Provider tab, leave the setting to the default, which is Microsoft OLE DB Provider for ODBC Drivers.
- 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)
NI Developer Community: How to Make a Parameterized Query into a Stored Procedure Routine with MySQL Databases
0 comments:
Post a Comment