Updating Identity Column in datatable

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am having a problem getting SQL Server to pass back to my datatable the value that it assigns to an identity column
I am using the Update method of a dataadapter and set the command text to the name of my stored procedure. The update method passes a datatable to SQL Server. Using enterprise manager I see that SQL Server inserted the row from the datatable and assigned a new value for the identity column, however when I display the value of the identity column from my datatable after the update, the value of the identity column is still -1. Do I need to query SQL Server for the value of the identity column and then assign it to the datatable?
 
Yes.
Either use multiple result sets or send another query to get the value.
Use ScopeIdentity!

ADO.Net by David Sceppa is a great book.
--
Joe Fallon



Gary said:
I am having a problem getting SQL Server to pass back to my datatable the
value that it assigns to an identity column.
I am using the Update method of a dataadapter and set the command text to
the name of my stored procedure. The update method passes a datatable to SQL
Server. Using enterprise manager I see that SQL Server inserted the row from
the datatable and assigned a new value for the identity column, however when
I display the value of the identity column from my datatable after the
update, the value of the identity column is still -1. Do I need to query SQL
Server for the value of the identity column and then assign it to the
datatable?
 
Back
Top