I am trying to update a table across “non-linked” SQL servers using:
C# or VB.net and ADO.net SqlDataAdapter.
I need to use DataTable and SqlDataAdapter.
Very Important: I need to use BatchUpdate and avoid looping through the DataTable.
The table designs in Server 1 differ from table design in Server 2.
Source Table:
Server 1. Table 1
ID INT
NAME Varchar(30)
Date DateTime
Destination Table:
Server 2. Table 2
ID INT
TableOneId INT (Foreign Key from Server 1. Table 1)
NAME Varchar(30)
Date DateTime
I need a sample on how to update table 2 on server 2 using SqlDataAdapter, or an alternative batch method.
You should set the UpdateBatchSize property of the SqlDataAdapter to 0 (unlimited).
I don’t see a way to update table2 without looping table1.
Here is a sample code to show you one way to achieve this: