LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Condition input to "db tools update data.vi"

I am trying to modify a database record based on the ID number. I looked at the Database Update.vi example but it has the Condition input of "db tools update data.vi" wired to a constant "where %s='%s' and %s='%s'  ". I cannot find anything that shows how to change one record based on the ID number.

0 Kudos
Message 1 of 10
(4,130 Views)

Simply wire a string constant to the condition input which is "WHERE ID = <DESIRED ID>". This is essentially the WHERE clause for your SQL statement. Make sure that 'ID' equals the column name of the column you are using and that "<DESIRED ID>" equals the actual user ID.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 10
(4,115 Views)

Since the <DESIRED ID> is not a constant, just concatenate strings to get the correct formatting?

0 Kudos
Message 3 of 10
(4,104 Views)

This code snippit did not work.

0 Kudos
Message 4 of 10
(4,093 Views)

What DB are you using?



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 5 of 10
(4,091 Views)

Microsoft JET Database Engine.

0 Kudos
Message 6 of 10
(4,088 Views)

Are you getting any errors? Is the ID field a string? Your syntax in the WHERE clause indicates it is a string column. Is ID a numeric column? If so, drop the quotes around the ID.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 7 of 10
(4,083 Views)

I dropped the quotes and no longer get any errors, but it changes all of the rows, only 5 fortunately, in the DB.

0 Kudos
Message 8 of 10
(4,069 Views)

Did the 5 rows all have the same ID? IF so, it did what you asked. If not, then something would appear to be wrong with the WHERE clause. To be honest, I rarely use most of the VIs in the DB toolkit. I generally only use Open, Close, Execute, and Fetch. My applications include the actual SQL in the code. As a rule of thumb, I generally only use stored procedures in the DB. This provides a nice API to the DB and allows changes to the schema without requiring changes to the application provided I maintain the calling structure of the stored procedures.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 9 of 10
(4,066 Views)

I gave up on "db tools update data.vi" and modified the "Database Fetching.vi" to read my data. It looks a lot easier to change and write the data. Time will tell.

0 Kudos
Message 10 of 10
(4,024 Views)