By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,731 Members | 1,129 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,731 IT Pros & Developers. It's quick & easy.

Updating DataSets with Identity On

P: n/a
I have a situation where I have two datasets each equal with the data
from the same table. I want to update one dataset with the records
from the next dataset IDs in tact. Here's the code I have:

' Set AcceptChangesDuringFill = False
objDataAdapterSource.AcceptChangesDuringFill = False
' Fill the data adapter with some data from the source "myTable"
objDataAdapterSource.Fill(objDataSetSource, "myTable")
' This is a function I wrote that just calls the "SET
SetIdentityInsert(True, "myTable")
' Select everything from myTable on the database toupdate and
' create a data adapter
strSQL = "SELECT * FROM myTable"
objDataAdapterDest= New SqlClient.SqlDataAdapter(strSQL, strConn)
' create a commandbuilder object
objCB = New SqlClient.SqlCommandBuilder(objDataAdapterDest)'
'Update the destination data set
objDataAdapterDest.Update(objDataSetSource, "myTable")

Let's say the Source object objDataSetSource had a "myTable" with two
columns" "TableID" and "Description" where "TableID" was the key.
Let's say it had one row, where the TableID = 1 and Description =
"TEST". I am expecting the same table in the destination database to
be inserted with the exact same data. Instead, the TableID ends up
being generated by the database as if Identity_Insert isn't turned on.
Any suggestions?

Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.