|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Comparing Two DataTablesScenario: I have to update my SQL server table from an ORACLE database
to keep my SQL table in sync with ORACLE. I have one data table that is populated form ORACLE and other one is populating from SQL server (Both data tables are part of the same dataset). How to programmatically compare two tables and update the SQL server data table? Thanks in advance. Other than data, will the comparison need to include schema differences
between the two tables? If so, does it need to update the columns as necessary in the SQL table? If its only data, then you can use the datatable's find method to pull back each row. Then iterate through the columns collection against both rows and check the individual values. Ie. Dim dtOracle as datatable = dataset.Tables("OracleTable") Dim dtSQL as datatable = dataset.Tables("SQLTable") for each oracleRow as DataRow in dtOracle.Rows Dim sqlRows() as datarow = dtSQL.Find(CINT(oracleRow("primarykeycolumnname"))) if sqlRows.length > 0 then for each field as datacolumn in dtOracle.Columns if sqlRows(0)(field.Name) <> oracleRow(field.Name) then sqlRows(0)(field.Name) = oracleRow(field.Name) end if next end if next Something like that. My code is probably wrong, so look at it as pseudo code! Hi,
This completely depend on how independen the data is from the time, is that not than you need beside a kind of code as Stevens pseudo code a timestamp in all datarows that you want to merge. I hope this helps, Cor Show quoteHide quote "c_shah" <shah.chi***@netzero.net> schreef in bericht news:1148433437.717744.213600@j55g2000cwa.googlegroups.com... > Scenario: I have to update my SQL server table from an ORACLE database > to keep my SQL table in sync with ORACLE. > > I have one data table that is populated form ORACLE and other one is > populating from SQL server (Both data tables are part of the same > dataset). How to programmatically compare two tables and update the SQL > server data table? > > Thanks in advance. >
DataRelation vs DataView.RowFilter property
Creating a "Back" button in VB.Net/ASP.Net Postmessage API Can't get true random numbers Wierd .NET Debugging behavior... Referencing Images... application.exit( ) Don't know how to pass data from form to module vb compile issue .Net Mail and hotmail question |
|||||||||||||||||||||||