[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

ERROR [07002] [Microsoft][ODBC Microsoft Access Driver]COUNT field incorrect

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?

3 Answers

chris

5/4/2006 4:24:00 PM

0

I found that if I don''t set a datetime field, it works fine. What is
happening that I can''t set a datetime field using a System.Datetime
object?

chris

5/4/2006 9:39:00 PM

0

Worked on some datetime fields, not others.

Ran find/replace and switched Odbc to OleDb and everything works
great...

Paul Clement

5/5/2006 12:11:00 PM

0

On 4 May 2006 14:38:44 -0700, "Chris" <chris@spatialdatatech.com> wrote:

&#164; Worked on some datetime fields, not others.
&#164;
&#164; Ran find/replace and switched Odbc to OleDb and everything works
&#164; great...

Yes, I would definitely avoid using ODBC and the Microsoft Access driver if possible. Jet OLEDB is
more stable and has better feature support.


Paul
~~~~
Microsoft MVP (Visual Basic)