0

I'm using a DataSet with the DataSet designer on xsd file (System.Data v 4 in VS 2015). I've been searching for how to get the ID for a newly created record. I see on the designer advanced options there is an option for reading back the record for insert and updates. I also see the SELECT included in the INSERT INTO statement. However the designer generated code runs ExecuteNonQuery and returns the number of records affected. How do we get access to that record that was read back in?

Most solutions I've read involve creating your own query or sp that is set to ExecuteScalar and selects the @@ROWIDENTITY. Either that or timestamp the new record and get it back that way. But if the read-back is already being done then I should be able to get to it, right? What' the trick? What happens to that data that's been read back in?

TIA, Mike

Mike
  • 788
  • 10
  • 27
  • Did you check this answer? http://stackoverflow.com/questions/3704394/getting-identity-from-tableadapter – Steve Feb 28 '16 at 18:20
  • Yes, I've seen that one. Again it calls for the user to create a new insert query or SP that requests the identity back. My observation is that this data is already being called back by the default generated insert query, but we appear to have no access to that returned data. – Mike Feb 29 '16 at 20:22

0 Answers0