4

I want to insert about 2000 records every time a button is clicked. It works fine until record 511, and throw this exception: Unspecified Error \r\n Object invalid or no longer set

I've debugged it several times with different records or different order and always get the same error on 511th record. What's happening?

CODE: (I read the ID of the last record, before i insert another one)

string CmdText = "SELECT TOP 1 Id FROM MyTable ORDER BY Id DESC";
OleDbCommand com = new OleDbCommand(CmdText,tran.Connection,tran);
com.CommandType = CommandType.Text;
OleDbDataReader reader = com.ExecuteReader(); //exception started here
3
  • Are you debugging with same records all the time? Commented Apr 4, 2013 at 7:28
  • no...With different records. Commented Apr 4, 2013 at 7:30
  • i think The foreign key of the table is an integer. Microsoft Jet is converting it to a decimal, and this causes the error in the query.add your table stracture Commented Apr 4, 2013 at 7:32

3 Answers 3

1

It sounds like somehow the Jet engine is not working properly or is corrupted.

When opening and closing connections or recordsets using the Microsoft ODBC Driver for Access or the Microsoft OLE DB Provider for Jet, the following error may be reported:

Object invalid or no longer set.

To resolve this problem, install the latest Microsoft Jet 4.0 service pack 6. For additional information FIX: "Object invalid or no longer set" Error with Microsoft Jet

Sign up to request clarification or add additional context in comments.

1 Comment

I didn't try it before but it might be helpful,the error may says some thing is not correct in Jet engine.
1

I've figured it out guys. I have to close OleDBDataReader every time i want to insert new record.

Now it works fine. Thanks.

Comments

0

The best way to resolve this problem is to delete that table in which its giving error in inserting / updating. and then re-create the table, but be sure, to backup the table data first.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.