LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI Inputting data into MS Access? Why does this VI not work? Suggestions?

Hello,
 
Any suggestions on why my VI does not work. It basically gets slope/y-intercept and is supposed to input it into Access.  The vi for getting slope/ y-intercept works, but getting the input into a table in MS Access is not.
 
Suggestions?
 
Thanks.
 
Enclosed attachment.
0 Kudos
Message 1 of 15
(3,728 Views)
Just to explain more clearly:
 
The goal is get the data to be written into the database of MS Access.
 
 
0 Kudos
Message 2 of 15
(3,710 Views)
I do not have any of the DB related subvi's.  There may be issues with those, but I cannot tell.

Looking at the picture, you need to disable indexing on the ref# and error tunnels leading to the DB close (?) subvi.  You cannot wire the input of the T/F array  indicator to the input of the bundle.
0 Kudos
Message 3 of 15
(3,692 Views)
Off-hand, I see things from the picture that might cause problems. The error cluster wire is supposed to pass through a shift register. In a for loop situation you must do this to allow the first error to shunt the rest of the loop iterations when there is an error. Second, the loop counter might possibly be the primary key of the table (the ID field). If you are writing to the same table over distinct executions of the vi, then you will be attempting to use the same primary key for a different row, and this will generate an error because primary key values have to be unique. You need to query the database to find the maximum value of the primary key and start your logging after that, or log to a new table. Three, there are a certain mumber of broken wires that need to be fixed. The error cluster broken wire would be fixed by using a shift register. The connection reference is passed out of the for loop with auto-index enabled (the default for the for loop). You may right click on the output tunnel and turn off auto-indexing in order to get a scaler. That is a solution that will work for newer versions of LabVIEW, but for older versions, if the loop never runs because "numeric" is zero, the connection reference will not be valid and you will not be able to close the database. It would be better to pass the connection reference around the loop, to the close vi, and allow the dataflow to mediate execution with the error cluster wire (this is the normal LabVIEW idiom). finally, the boolean array seems to be a problem that you will have to sort out. If it is in fact accidentally an indicator rather than a control then its dimension will control the number of iterations of the loop, unless "numeric" is less than 'array" dimension, in which case 'numeric will. This could be an additional "got ya" once you get it to talk to Access. Just from looking at the picture, where I assume that the cluster bundle is representative of the table row, what is a string array doing in there? What SQL datatype does that map to?
Message 4 of 15
(3,685 Views)
Off-hand, I see things from the picture that might cause problems. The error cluster wire is supposed to pass through a shift register. In a for loop situation you must do this to allow the first error to shunt the rest of the loop iterations when there is an error.

Thanks.  The shift register suggestion worked.  Great explanation--- very direct

Second, the loop counter might possibly be the primary key of the table (the ID field). If you are writing to the same table over distinct executions of the vi, then you will be attempting to use the same primary key for a different row, and this will generate an error because primary key values have to be unique. You need to query the database to find the maximum value of the primary key and start your logging after that, or log to a new table.
 
How do I log to a new table? Also how does one go about querying the database to find the maximum value of the primary key
 
Three, there are a certain mumber of broken wires that need to be fixed. The error cluster broken wire would be fixed by using a shift register.
 
Now solved
 
The connection reference is passed out of the for loop with auto-index enabled (the default for the for loop). You may right click on the output tunnel and turn off auto-indexing in order to get a scaler.
 
 
That is a solution that will work for newer versions of LabVIEW, but for older versions, if the loop never runs because "numeric" is zero, the connection reference will not be valid and you will not be able to close the database. It would be better to pass the connection reference around the loop, to the close vi, and allow the dataflow to mediate execution with the error cluster wire (this is the normal LabVIEW idiom). finally, the boolean array seems to be a problem that you will have to sort out. If it is in fact accidentally an indicator rather than a control then its dimension will control the number of iterations of the loop, unless "numeric" is less than 'array" dimension, in which case 'numeric will. This could be an additional "got ya" once you get it to talk to Access.
 
 Can you attach an example of what you mean using what I have already if possible.
 
Just from looking at the picture, where I assume that the cluster bundle is representative of the table row, what is a string array doing in there? What SQL datatype does that map to?
 
Cluster bundle is representative of the table column.  The string array was meant to reflect the presence of the tables.  I really wanted to have the array reflect the current slope and y-interecept from my subvi from the table. Everytime new data is entered for one axis, one would get a new slope and y-intercept to replace the older calibration.  The new information would then automatically enter the table.
0 Kudos
Message 5 of 15
(3,673 Views)
Thanks for your help.  Here's a jpeg attachment
0 Kudos
Message 6 of 15
(3,672 Views)
Hello,
 
I made my subvi have only one output terminal (the slope) so that  it is entered into the table.
 
It has no wire problems, but it does not work like it should.
 
Any suggestions.
 
Enclosed jpeg.
 
Thanks.
0 Kudos
Message 7 of 15
(3,653 Views)
Sorry, forgot to attach jpeg.
 
Enclosed jpeg.

Message Edited by roboticstudent on 12-06-2005 12:07 PM

Download All
0 Kudos
Message 8 of 15
(3,655 Views)
Here's my newer version.  What do you think?
 
I keep getting an error:   "The file provided is not a data link (UDL) or a file DSN."
 
But I do provide this information in the front panel.
 
Thanks for the help and patience.
0 Kudos
Message 9 of 15
(3,650 Views)
The "UDL" file is a link or pointer to your database file.
 
 
Once you've created the UDL file, right click on it and pont it to your database.  Then, put the UDL's file name, including all of it's path info, in your "connection information" control.
 
Mike
 
 
Message 10 of 15
(3,566 Views)