Mar 14, 2012
Programming Experience
I have a button in my form and on click of that button I am writing this code....

OdbcCommand cmd ;
cmd = new OdbcCommand("abc", cn);
cmd.CommandType = CommandType.StoredProcedure;

I have made a procedure named abc in database which is returning only
one row from login table..So i am just checking that on click of that
button my procedure should run but while debugging when i come to
cmd.ExecuteQuery() it throws following error..

ERROR [42000] [MySQL][ODBC 5.1 Driver][mysqld-5.0.77-community-nt]You
have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'abc()' at
line 1.

So plz sort out the problem as soon as possible...
At a glance it looks OK, so i can only assume that MySQL requires something special to execute a procedure like that that SQL Server doesn't. That said, I have a couple of suggestions for changes to make and, if you can make them, you should see if the issue goes away.

First, if you want to execute a query then calling ExecuteNonQuery is not the way to do it. You should be calling ExecuteScalar or ExecuteReader or else using a data adapter and calling Fill.

Second, you should download Connector/Net from the MySQL web site and use it. It is a MySQL-specific ADO.NET provider. You'll use the MySql.Data.MySqlClient namespace instead of the System.Data.Odbc namespace.
Top Bottom