Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ERROR [HY000] Object invalid or no longer set. 1

Status
Not open for further replies.

dzisaacs

Programmer
Dec 12, 2002
53
PA
I have an application that inserts records to a database, and it works perfectly on mysql

when i try to insert the records on access after inserting 340 records i get this error message that says

ERROR [HY000][Microsoft][ODBC Microsoft Access Driver] Object invalid or no longer set.

Is there any reason why i'm getting this message?

I'm connecting fine to the database because i'm inserting records, but it suddenly stops and i don't know why
 
MSDN said:
An error occurred for which there was no specific SQLSTATE and for which no implementation-specific SQLSTATE was defined. The error message returned by SQLGetDiagRec in the *MessageText buffer describes the error and its cause.
MSDN Link

________________________________________________________
Zameer Abdulla
Help to find Missing people
There’s a world of difference between editorials and advertorials
 
Not exactly..
There can be syntax error that causes the problem. (I mean the syntax might be right for MySql and wrong for JetSQL )

There can be some one who can help you on amending the code If you post it here; if there is any mistake..

________________________________________________________
Zameer Abdulla
Help to find Missing people
There’s a world of difference between editorials and advertorials
 
protected int MaxID( String table )
{
String id = "-1";
// I need to get the ID of the last element in the table
String query = "SELECT max(id) from " + table + "";

OdbcCommand command = new OdbcCommand( query, this.m_ConnectionObject );

try
{
// THIS IS THE LINE THAT CRASHES
this.m_reader = command.ExecuteReader();
}
catch
{
MessageBox.Show("I need to fix it here");
}

try
{
// Always call Read before accessing data.
while ( ( this.m_reader ).Read())
{
// the last id of the table is now stored in id
id = ( this.m_reader ).GetString(0);
}
}
catch
{
id = "-1";
}
( this.m_reader ).Close();

return Convert.ToInt32( id );
}
 
m_reader is a OdbcDataReader
OdbcDataReader m_reader;
 
What is the actual value of table ?
You may try this:
String query = "SELECT max(id) from [" + table + "]";

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
that was actually extremely helpful...it's incredible i was missing that
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top