M
mik
I'm trasferring data (syncronization) from a MDB to another MDB using the
OleDbCommandBuilder facilities.
sql = "select * from agenti";
ds = new DataSet("Agenti");
db.FillDataSet(sql, ref ds, ref transactionSql);
foreach (DataRow row in ds.Tables["Agenti"].Rows)
{
sql = "select * from Agenti where ID=" + row["ID"];
DbDataReader rd1 = Program.DB.ExecuteReader(sql, ref transactionOle);
rd1.Read();
if (rd1.HasRows)
{
// caso insert
row.SetModified();
}
else
{
// caso insert
row.SetAdded();
}
rd1.Close();
rd1 = null;
}
OleDbDataAdapter da;
OleDbCommandBuilder cb;
da = new OleDbDataAdapter("select * from " + tableName + " where 0=1",
(OleDbConnection)conn);
cb = new OleDbCommandBuilder(da);
cb.QuotePrefix = "[";
cb.QuoteSuffix = "]";
da.SelectCommand.Transaction = (OleDbTransaction)transaction;
cb.RefreshSchema();
da.Update(ds, tableName);
The insert statements are correctly completed, but the update not: the
updated rows are skipped.
Please help me
Thanks in advance
OleDbCommandBuilder facilities.
sql = "select * from agenti";
ds = new DataSet("Agenti");
db.FillDataSet(sql, ref ds, ref transactionSql);
foreach (DataRow row in ds.Tables["Agenti"].Rows)
{
sql = "select * from Agenti where ID=" + row["ID"];
DbDataReader rd1 = Program.DB.ExecuteReader(sql, ref transactionOle);
rd1.Read();
if (rd1.HasRows)
{
// caso insert
row.SetModified();
}
else
{
// caso insert
row.SetAdded();
}
rd1.Close();
rd1 = null;
}
OleDbDataAdapter da;
OleDbCommandBuilder cb;
da = new OleDbDataAdapter("select * from " + tableName + " where 0=1",
(OleDbConnection)conn);
cb = new OleDbCommandBuilder(da);
cb.QuotePrefix = "[";
cb.QuoteSuffix = "]";
da.SelectCommand.Transaction = (OleDbTransaction)transaction;
cb.RefreshSchema();
da.Update(ds, tableName);
The insert statements are correctly completed, but the update not: the
updated rows are skipped.
Please help me
Thanks in advance