Reputation: 183
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
Upvotes: 4
Views: 1006
Reputation: 1
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.
Upvotes: 0
Reputation: 183
I've figured it out guys. I have to close OleDBDataReader every time i want to insert new record.
Now it works fine. Thanks.
Upvotes: 1
Reputation: 10153
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
Upvotes: 1