build insertcommand of dataadapter manually + select @@identity

  • Thread starter Thread starter Anton Sommer
  • Start date Start date
A

Anton Sommer

Hello folks,


I try to build the InsertCommand of a DataAdapter manually so that the
PrimaryKey value in the aplications DataTable is changed to the value that
is returned by the select @@identity. Of course the PrimaryKey Value in the
DataTable is -1...
When I let the DataAdapter be created by visual studio, it is performing
alright.
But when I create my own insertcommand it only inserts data but the
DataTables PrimaryKey is not updated, although I have added to the
insertcommand.commandtext+=" select @@identity as MyCol" and have set the
UpdatedRowSource to both.

Any ideas how the I can make it update my table.


Thank you


Anton
 
make it

insert into ...
select @parameter = @@identity

make sure, @parameter is inputoutput parameter.

Try that.

Rajesh Patel
 
Back
Top