|
-
May 24th, 2007, 08:01 AM
#1
Getting IDs for newinserted rows
Hello!
I insert some new rows into a DataTable and then insert the rows into the database via
Code:
changes = dataTable.GetChanges();
if (changes != null)
{ int nRowsUpdated = dataAdapter.Update(changes);
}
This works fine. But now I need to know to values of the "auto_incremet primary key" the database gave to this new rows. So how can I get the ids of the records I just inserted?
-
June 5th, 2007, 11:01 PM
#2
Re: Getting IDs for newinserted rows
Busy 
-
June 20th, 2007, 11:12 PM
#3
Re: Getting IDs for newinserted rows
-
June 26th, 2007, 05:42 PM
#4
Re: Getting IDs for newinserted rows
 Originally Posted by martho
Hello!
I insert some new rows into a DataTable and then insert the rows into the database via
Code:
changes = dataTable.GetChanges();
if (changes != null)
{ int nRowsUpdated = dataAdapter.Update(changes);
}
This works fine. But now I need to know to values of the "auto_incremet primary key" the database gave to this new rows. So how can I get the ids of the records I just inserted?
call this instead:
int nRowsUpdated = dataAdapter.Update(datatable);
and note how your id fields are all now popualted. magic
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|