LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Insert and return an auto-generated ID into a MS SQL database using the LabVIEW database connectivity toolkit

Hi, 

I need to insert data into a table with an (database) autogenerated ID using the database connectivity toolkit. After inserting the data I want to read back the newly generated ID.

To make sure I'm always fetching the ID of "my" dataset I would run SQL code like this:

INSERT INTO MyTable (Text)

VALUES ('Hello');

SELECT @@IDENTITY AS 'Identity';

SELECT MAX(ID) FROM MyTable;

 

 

If I'm executing this query in LabVIEW in one execution (DB Tools Execute Query.vi), I will not fetch any data from the database. I will have to split it into two executions, as shown in the appended LabVIEW example.

 

My question: Will I always get "my" ID, or is there a chance someone else may generate a different ID in between the two executions? What effect are the DB Tools Free Object.vi-vis actually have?

Download All
0 Kudos
Message 1 of 1
(1,933 Views)