From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Insert data to SQL database table

Solved!
Go to solution

Hello,

 

   I am using the Database connectivity toolkit that comes with LabView 2017. I am trying to insert data into a SQL database table. Right now, LabView successfully connects to the database, but when it goes to insert data I get the error "Error 1... the number of columns does not equal the number of parameters." I seen much older threads with this issue but without any real solutions. As you can see from the attachments, the columns in LabView match the database column headers exactly, and the VI only wants 1-D array strings (previous threads suggested using clusters). Any help on this issue would be greatly appreciated. I'm kind of banging my head against the wall at this point.

 

   Thank you,

      Matt

Download All
0 Kudos
Message 1 of 8
(5,275 Views)

Can this somehow be related to the data type you have as in "Data"  As far as I see at the help of  DB Tools Insert Data VI "data" does not seem to be an array? 

0 Kudos
Message 2 of 8
(5,247 Views)

That's a good point, but yesterday I tried entering data as a string cluster, and then as I cluster with I32 numbers and still got the same error. Both with a "True" constant wired into "flatten cluster" but both these types gave me the same error.

0 Kudos
Message 3 of 8
(5,240 Views)

Please move this discussion to the LabVIEW forums.

 

This forum is for LabVIEW Communications.

 

Thanks!

0 Kudos
Message 4 of 8
(5,238 Views)

Ok, I'm not quite sure how to do that though.

0 Kudos
Message 5 of 8
(5,232 Views)

I can't open your 2017 VI but are you sure you're not trying to write to an ID (primary key) column that the database is set to auto-increment?

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 6 of 8
(5,203 Views)
Solution
Accepted by topic author MattManML

I figured it out with the help of one of the database guys at my work. So that you guys can spread the word if you see this again, the issue was that when the SQL database is created, each column is given a specified type. In LabView, you must make sure that the type of the data you are inputting for that column matches what SQL is expecting. Also, each column you input should be entered into a bundle which is then wired to the "data" part of the VI.

Message 7 of 8
(5,165 Views)

Thanks for reporting back after you figured it out.  Smiley Happy

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 8 of 8
(5,153 Views)