0

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,

4
Contributors
6
Replies
7
Views
11 Years
Discussion Span
Last Post by michael!
0

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();
0

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?

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.