i am using c# with a MySQL database, using OleDbConnection and OleDbReader.

When running a query using the count(*) function and try reading the returned value using:

OleDbReader.getInt32(0), it gives an exception "Index was outside the bounds of the array".


thanks,

So, I'll give you two solutions, you can go to MySQL site and Install their libraries to work on .NET (Better than using OLE Classes)

Second, why you use Reader??! Count(*) returns ONE VALUE so you should use execute SCALAR and cast the returned value

int Count = (int)myCommand.ExecuteScalar();

When using the ExecuteScalar, the returned value is NULL. Any ideas?

I have an application which was using MS Access and using OLE DB all over the place. I need to change the db to be MySQL. I would prefer not want to change from OLE classes.
If needed I'll do as you told me to install the MySQL libraries to work on .NET. Are refering to the ODBC classes?

Sorry, I have no idea

No, As I think

I did not work by their classes, I saw that in article showing how their libraries is better than OLE,......... classes

==When using the ExecuteScalar, the returned value is NULL. Any ideas?

Is your sql right?

Whatever, it should return 0 (ZERO) if it does not meet the criteria.
His error is bit strange!!

Did you try to use "double" instead of int32?