Showing results for 
Search instead for 
Did you mean: 

Writing data to a database

Go to solution


I have created a datalogging app but I have had no joy at all trying to write the data to a database.

The small vi attached creates a database in c:\DBase\ and then you can write data into it. I get no errors at all from this code but the database remains empty.

I am using Windows 10 64bit, LabView Pro 2016 32 bit and currently SQL Server 2016 32bit. I have tried a few versions of SQL server, the server is running and appears configured ok.


If anyone can spot an error in my app or can confirm this works ok on a different version of LAbview or SQL then it would help greatly.


Thank you


0 Kudos
Message 1 of 6
I can't open your VI as I only have LV2014 but...

When you say the VI creates a database - are you sending SQL commands to the server to create the database? Does the user you are performing this with have the correct permissions on the server to create databases (normally admin-type rights)?

Does the user have the correct rights to then write to that database? You might need to 'GRANT' some rights to the user if they are not there by default.

Have you tried creating the database in the SQL management studio and tried just writing to it from LabVIEW first just to check you have the connections etc. set up correctly?

LabVIEW Champion, CLA, CLED, CTD
0 Kudos
Message 2 of 6

Thanks for replying Sam.

The database create was easy to get working. I then used an example vi I found to create a table in the database,  in my vi when it writes the data I also have it reading the column headers out from the database.

 In the image I have created a database, the path and connection string are displayed. Then in the lower area I have saved the data stored in the readings matrix along with some other info. There are no errors from either process.

You can see the column headers read from the database match the column headers I am sending data to.


I should also say I am using Access to look for data within the database.



Download All
0 Kudos
Message 3 of 6

First of all, you have Data to Variant, no need for that. Wire the cluster directly input the DB function. 


How are you getting data out of the .mdb file? 


0 Kudos
Message 4 of 6

I have now sent the data direct, no more variant but no change to the outcome sadly.

I am using access to check if data is present, also I see the file size does not grow no matter how many times I save data so I feel sure the data doesn't make it.


I am concerned that opening the database in access may ruin it for labview. If I open and save a spreadshet in excel labview will no longer work with it. I don't know if I will have the same problem with access, it does increase the file size from 80kb to 228kb simply by opening the file, no saving, just open and close the file and it grows.


For now I can simply create another database file each time until I see data being saved.



0 Kudos
Message 5 of 6
Accepted by topic author STTAndy

OK I have this sorted now. Should be 'insert' not 'update' Smiley Frustrated

Too embarassed to say how long I looked at this problem Smiley Very Happy


Thanks for the help.

Onwards and upwards

0 Kudos
Message 6 of 6