OleDbDataReader ????

  • Thread starter Thread starter Darryn Ross
  • Start date Start date
D

Darryn Ross

Hi...

I am trying to trying to execute a database reader and i keep getting the
following exception error...

{"IErrorInfo.GetDescription failed with E_FAIL(0x80004005)." }
System.Exception

I have not idea what this error means, or how to resolve the issue, if you
have any suggestions please let me know. The code i am running is as
follows....

int ID = 0 ;


OleDbConnection Connection = new OleDbConnection() ;

try {


//Database Connection

Connection.ConnectionString = AppMain.CompanyConnectionPath ;

OleDbCommand Command = new OleDbCommand("Select * From tbl WHERE LOWER <=" +
51.01 + " AND UPPER >=" + 51.01, Connection) ;

//Open the connection

Connection.Open();

//Create an instance of a data reader

OleDbDataReader Reader ;

//Setup data reader CommandBehavior.CloseConnection

Reader = Command.ExecuteReader(CommandBehavior.CloseConnection) ; // error
occurs here!


while(Reader.Read()) {

//Chart of Accounts Information

pID = Convert.ToInt32(Reader["ID"]) ;

}

Reader.Close() ;

Command.Dispose() ;

}

catch(Exception e) {

MessageBox.Show(e.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error) ;

}

finally {

Connection.Close() ;

}

return pID ;
 
Hi,

The same works fine on my machine!

Not sure what the exact cause of the error is.

Did you try by directly executing the DataReader without
any parameters
myReader = myCommand.ExecuteReader
(CommandBehavior.CloseConnection);

instead use
myReader = myCommand.ExecuteReader(); and see what the
behaviour.

Also, I ran the same code on my machine that has .NET 1.1
and VS.NET 2003

Thanks,
irfan
 
Back
Top