Hello,
I have written an app that does a deep clone copy from an MS Access database, migrates and inserts the data to another.
The following is my current implementation:
..........
1. I'm using the strongly typed DataSet classes code-gened by VS2008 when you add an OleDb (MS Access) data source.
2. "DestDataSe t" and SrcDataSet share the same schema.
..........
Is there a better way of populating the row? I've tried using
but adpA.Update() after the loop does not seem to insert the data into the Db even though there was no runtime execption.
Thanks!
I have written an app that does a deep clone copy from an MS Access database, migrates and inserts the data to another.
The following is my current implementation:
..........
1. I'm using the strongly typed DataSet classes code-gened by VS2008 when you add an OleDb (MS Access) data source.
2. "DestDataSe t" and SrcDataSet share the same schema.
..........
Code:
private void copy(DestDataSet dsDest, SrcDataSet dsSrc)
{
for (int i = 0; i < dsSource.TableA.Count; i++)
{
DestDataSet.TableARow rowDest = dsDest.TableA.NewTableARow();
if (!((SrcDataSet.TableARow)dsSrc.TableA.Rows[i]).IsCol1Null())
rowDest.Col1 = ((SrcDataSet.TableARow)dsSrc.TableA.Rows[i]).Col1;
// repeat for Col2,..., Coln
dsDest.TableA.Rows.Add(rowDest);
}
try
{
DestDataSetTableAdapters.TableAAdapter adpA = new DestDataSetTableAdapters.TableAAdapter();
adpA.Update(dsDest.TableA);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
Code:
foreach (SrcDataSet.TableARow row in dsSrc.TableA.Rows)
dsDest.TableA.ImportRow(row);
dsDest.AcceptChanges();
Thanks!
Comment