Execute store procedure using MySQL ODBC 3.51 provider in .NET 2.0
Posted by: rockdale green
Date: January 25, 2007 04:01PM

Hi, all:

I am trying to move from MS SQL to MySQL, my application is using ASP.NET. I am using ODBC driver, I can execute sql statement against mySQL, but when I execute stored procedure, I always got error
ERROR [23000] [MySQL][ODBC 3.51 Driver][mysqld-5.0.27-community-max]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 '{call usp_test();}' at line 1.

following is my Code, somebody please help...

string sqlStr = "select member_name from members where member_id = 1234";
string sqlCommand = "{call usp_test();}";


string mySQLConnStr = ConfigurationManager.ConnectionStrings["ODBC"].ToString();
OdbcConnection myOdbcConn = new OdbcConnection(mySQLConnStr);
//OdbcDataAdapter myOdbcDa = new OdbcDataAdapter();
myOdbcConn.Open();
OdbcCommand myOdbcCom = new OdbcCommand(sqlStr, myOdbcConn);
myOdbcCom.CommandType = CommandType.Text;
string rtn2 = myOdbcCom.ExecuteScalar().ToString();

OdbcCommand myOdbcSP = new OdbcCommand(sqlCommand, myOdbcConn);
myOdbcSP.CommandType = CommandType.StoredProcedure;
string rtn3 = myOdbcSP.ExecuteScalar().ToString();

myOdbcConn.Close();
myOdbcConn.Dispose();

Options: ReplyQuote


Subject
Written By
Posted
Execute store procedure using MySQL ODBC 3.51 provider in .NET 2.0
January 25, 2007 04:01PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.