LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Delete or insert a record into a database table

Hello everyone.

I am trying to include or delete the nth record of a table in a database (database connectivity toolkit).

Any ideas?

Thanks in advance. 

 

0 Kudos
Message 1 of 11
(7,035 Views)

@labviewette wrote:

Hello everyone.

I am trying to include or delete the nth record of a table in a database (database connectivity toolkit).

Any ideas?

Thanks in advance. 

 


DELETE FROM [a table] WHERE [record] = "nth"

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 2 of 11
(7,009 Views)

To elaborate on Jim's response:

Capture.PNG

aputman
0 Kudos
Message 3 of 11
(7,002 Views)

Thank you both !

0 Kudos
Message 4 of 11
(6,985 Views)

Dear Jim and aputman,

I am not getting this working yet. In the case of updating a record:

If I set the "DB Tools Update Data.vi" condition to be record='10' (for example) then I get error -2147217900.

If t set the vi's condition to be WHERE record='10' then I get error -2147217904.

 

0 Kudos
Message 5 of 11
(6,958 Views)

We were being a bit facetious in our response by setting the condition to be record='nth'.  In order for that to work, you have to have a table named "a table" (which is illegal because of the space...pick a meaningful table name), and the table should have a column named 'record' that has a datatype of char(3).  If the datatype of your column is actually an INT, and you want to update all entries (or delete all entries) that have a 'record' value of 10, you need to remove the quotes (WHERE record=10).  I screwed up in my image and left off the WHERE keyword.  

 

What database engine are you using?  Do you have a table created?  Have you built a connection string that creates a successful connection in the Open Connection VI?  

aputman
0 Kudos
Message 6 of 11
(6,952 Views)

aputman is right.
I would like to add a possible insert code. Assuming you would like to update a whole row you can just use a cluster as input.
Instert data.png

0 Kudos
Message 7 of 11
(6,931 Views)

@labviewette wrote:

Dear Jim and aputman,

I am not getting this working yet. In the case of updating a record:

If I set the "DB Tools Update Data.vi" condition to be record='10' (for example) then I get error -2147217900.

If t set the vi's condition to be WHERE record='10' then I get error -2147217904.

 


Please share details about the table you want to update: name, fields & data types should get us started.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 8 of 11
(6,911 Views)

Here is an excerpt of the database. The table's name is "table".

How can I update or delete the last record when I do not know the ID?

I am aware that this is more of an SQL than a LabVIEW question.

 

0 Kudos
Message 9 of 11
(6,904 Views)

Search for the record where rowid=max(rowid).


GCentral
0 Kudos
Message 10 of 11
(6,894 Views)