3
Reply

Fill a DataSet from a data source and update another data source

Kamran

Kamran

Feb 7 2007 6:34 AM
3.5k

My task is to fill a DataSet from a data source and update another data source in C#.

For example I have two databases in SQL Server (i.e. db1 and db2).
I have table named ProdMkt_Contrib_Link in db1 with following columns:

ProdMkt_Contrib_Link
--------------------
ProdMktContributorID (PK)
ProductMarketID
Priority
Inactive
Contrib_Type_Override
ProdMkt_Contrib_Link_ID

The above columns data should be mapped/sync to the table named ProdMktContribLink in db2:

ProdMktContribLink
------------------

ProdMktContributorID (PK)
ProductMarketID
Priority
InactiveFG
ContribTypeOverRide
AcumenProdMktContribLinkID

Note: The table name and few column name are different.

Suppose few records are added and few are updated in the b1.ProdMkt_Contrib_Link table.

I have filled the typed DataSet (DS1) with db1.ProdMkt_Contrib_Link (this contains only added and updated records) ans also filled the another DataSet (DS2) with db2.ProdMktContribLink (this contains all records).

Now I want that DS1 should be sync with the DS2. That is, the added records should be added to the DS2 table rows and also updated records should be updated to the DS2 table rows.

What is the best way to accomplish this in c#. Please suggest any good design or sample code.

Thanks,
Kamran


Answers (3)