Example Code

Connect to Database Server Without System DSN Using ODBC and LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW
  • Other

Code and Documents

Attachment

Overview
This example VI shows how to change the values of a DAQmx task that is currently running without implementing the changes that exact moment. 


Description
You can change DAQmx task values during the VI running. The VI is accomplished through the use of conditional statements such as Case Structures and the First Call function.


Requirements

  • LabVIEW 2012 (or compatible)
  • LabVIEW database 2012 (or compatible)
  • ODBC 5.0.1 (or compatible)

Steps to Implement or Execute Code

1.Download the attached VI's and save them to a single location.

2.Open Connection Example.VI and enter the required connection parameters on the front panel.

3.Run the VI to connect to the database sever.

4.If no errors are generated the connection was successful. 

Additional Information or References
VI Snippet

00.png

**This document has been updated to meet the current required format for the NI Code Exchange.**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
InfiniteNothing
Active Participant
Active Participant
on

It should be noted that the above probably won't work on a 64 bit machine. You'll get one of these errors:

  • FileNotFoundException
  • Data source name not found and no default driver specified
  • The specified DSN contains an architecture mismatch between the driver and application

The correct connection information string starts with something like DRIVER={MySQL ODBC 5.2w Driver}. You may have to download the 32 bit connection tool to make that work: http://dev.mysql.com/downloads/connector/odbc/

The string inside the braces {MySQL ODBC 5.2w Driver} should reflect the name you see in the "Create New Data Source" prompt when you try and create a new DSN from the 32 bit version of ODBC Data Source Administrator (not the version in the control panel, the version in C:\Windows\SysWOW64) If someone knows how to programmatically generate a list of those driver names, that might be handy.

CLED (2016)