LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SQL insert data Error 0x00000001 Num columns not= num params

As seen in the snippet, Im literally feeding the column head list to the insert data functoin... Please reveal to me what I'm not comprehending. Thanks in advance 🙂

Labview being silly again with SQL.png

0 Kudos
Message 1 of 4
(210 Views)

More than likely, it's not Labview being silly but rather the programmer. 😁

 

Error 1 is more of a general error that indicates a problem with the parameters or columns.  Obviously, you are giving it 21 columns of data but there may be something wrong with one of those columns.  Could be the wrong datatype, could be a permission issue.  Do you have the correct ODBC driver?  Can you verify that your connection to the database is being properly established?

aputman
0 Kudos
Message 2 of 4
(192 Views)

Couple of recommendations:

 

  • Don't query the column information like that in a production scenario.  That will add a lot of overhead to your query and, depending on how many columns you end up needing and how many times you write to the dB, can really slow down your application. 
  • Take advantage of stored procedures...they work really well.  Can process/manipulate parameters before writing them to the dB.  Can modify procedure without recompiling your application.  
  • Don't store everything to dB as a string.  Pick an appropriate datatype for each column.  Full text searches on strings takes an enormous amount of time.  If necessary, create an index on columns that you will use most often for searches to speed up your searches.  What good is a table full of data that you can't efficiently search thru? 
aputman
0 Kudos
Message 3 of 4
(181 Views)

TLDR: check the size of cluster that the conversion function outputs.

 

Your specific issue is likely with the data itself. You have an array which you convert to a cluster, because that's the data type that the insert VI expects. Clusters must have a fixed number of elements, but LV can't know how many on its own (since array sizes can change at run time), so you have to right click the conversion function and open the dialog to select the number of elements (21, in your case). I'm guessing you didn't do it, because it's easy to miss. The general idea behind this is that you already have a cluster which matches the structure of the table, not that you convert an array to be a cluster.

 

Other than that, I would agree with the other comments made.


___________________
Try to take over the world!
0 Kudos
Message 4 of 4
(119 Views)