Murray Brown
asked on
VB.net SQL Get Primary Key/ID number on Insert
Hi
What VB.net code would I use to insert a record and then get the primary key or ID value
of the newly inserted record?
What VB.net code would I use to insert a record and then get the primary key or ID value
of the newly inserted record?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ok.. too many solutions. The idea here is to append a SELECT statement that gives the last used identity value, to your regular INSERT query, and then execute the command using ExecuteScalar() instead of ExecuteNonQuery() method. ExecuteScalar will give you a single column single row result.
ASKER
Thanks very much