chris
5/4/2006 3:47:00 PM
Hello,
I'm running into a big problem here. I'm trying to update an Access
Database from a .NET 2.0 program programatically. The code I'm using
for the update is here:
CPodbcTransferDef TD =
(CPodbcTransferDef)_MyTransferDef;
UpdateConnection = new
OdbcConnection(TD._ConnectionString);
MyDataAdapter = new OdbcDataAdapter();
MyTable = new DataTable(_Name);
MyDataAdapter.TableMappings.Add(_Name, _Name);
UpdateConnection.Open();
OdbcCommand Cmd = new OdbcCommand("SELECT * FROM [" +
_Name + "]", UpdateConnection);
Cmd.CommandType = CommandType.Text;
MyDataAdapter.SelectCommand = Cmd;
MyDataAdapter.FillSchema(MyTable, SchemaType.Source);
MyDataAdapter.Fill(MyTable);
//Modify data in table.
OdbcCommandBuilder commandBuilder = new
OdbcCommandBuilder(MyDataAdapter);
commandBuilder.QuotePrefix = "[";
commandBuilder.QuoteSuffix = "]";
MyDataAdapter.Update(MyTable);
UpdateConnection.Close();
It works about 60 % of the time. Other times I get ERROR [07002]
[Microsoft][ODBC Microsoft Access Driver]COUNT field incorrect.
The complete stack trace is:
at
System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs
rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at
System.Data.Common.DbDataAdapter.UpdatedRowStatus(RowUpdatedEventArgs
rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows,
DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.UpdateFromDataTable(DataTable
dataTable, DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataTable dataTable).
Could anyone offer some insight as to what is causing this error?