S
shootsie
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
' IDENTITY_INSERT myTableON"
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?
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
' IDENTITY_INSERT myTableON"
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?