The best and easiest way to perform database connection and operations in LabVIEW is by using the LabVIEW Database and Connectivity Toolkit.
This comes with a simple API that allows for the creation of routines that work with the most popular databases. These include:
- Microsoft Access
- SQL Server
The Database and Connectivity Toolkit also provides a set of advanced functions to access low level operations.
Sample code that exemplifies the usage of this Toolkit can be found below. This is a native example that comes with the Toolkit, and can be found by clicking Help>> Find Examples >> Toolkits and Modules >> Database Connectivity
This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.
When communicating with a database, the general workflow will be:
Open a connection to the database -> manipulate data (i.e. inserting tables, fetching Recordsets and executing queries) -> Close the database connection.
This workflow can be achieved using the LabVIEW Database Connectivity Toolkit VIs