08-05-2010 08:42 AM
Hi All,
I'm trying to insert a 25 element array of doubles (after appending the current date/time in seconds) into a database (LV 6.1) row by row, however, I keep coming across the following error:
-2147467259 Exception occured in Microsoft JET Database Engine, Number of query values and destination fields are not the same..
Which I don't quite understand because when I initialize the SQL query, I use 25 elements and my array is 25 elements.
After following the execution path using the highlight function, it appears the error is generated in the Cmd Execute VI as shown below.
What am I doing wrong or is there an simpler way to go about doing this?
Thanks in advance!
-Cameron
08-06-2010 11:52 AM
viCam,
You can only insert one row at a time into the database, and you are trying to insert 25.
I've never used these NI db vis, but it looks like your sql query needs to have as many question marks (?) as there are parameters in your Parameters array (i.e. 7). Then you need to fill in all 7 of those parameters, one of which will be one element of your Input Array. Then you will need to run the Execute Query vi 25 times to insert all 25 elements into the table in your database.
this means: your exe vi and the close connection vis after it need to go inside your for loop. and the index ("i") of your for loop should *not* be wired to "parameter index", that should be a static number indicating which of the seven parameters is supposed to be filled with your array element.
hope this helps
08-06-2010 01:57 PM
Hey Michael,
Thanks for responding. I actually was trying to follow the wrong example for my purposes. Turns out to be MUCH easier when I used the "Logging Example.vi" instead of "Logging Example(parameterized).vi". There you can input entire arrays by converting them to clusters.
Thanks again,
-C