Enterpriselibrary with mysql stored procedures output parameter

Topics: Data Access Application Block
Nov 26, 2013 at 4:27 AM
Edited Nov 26, 2013 at 4:27 AM
down vote
My stored procedure:

CREATE DEFINER=AS0058@% PROCEDURE getName(IN eid INT,INOUT ename VARCHAR(50)) BEGIN Select fname into ename from emp where empid=eid; END

ASP.NET C# program using enterprise library:

DbProviderFactory dbProviderFactory = DbProviderFactories.GetFactory("System.Data.Odbc"); string connect = "Dsn=emp;uid=AS0058;pwd=best@123"; Database db = new GenericDatabase(connect, dbProviderFactory); DbCommand cmd = db.GetStoredProcCommand("{call getName(?,?)}"); db.AddInParameter(cmd, "empid", DbType.Int32, 2); db.AddOutParameter(cmd,"fname",DbType.String,45); //db.DiscoverParameters(cmd); db.ExecuteScalar(cmd);// The error is thrown at this place:OUT or INOUT psuedo variable trigger
string results = Convert.ToString(db.GetParameterValue(cmd,"fname")); MessageBox.Show(results);

Please suggest me a solution:
Nov 27, 2013 at 2:02 PM
The error you are seeing is raised by MySQL. I'm not familiar with MySQL but it looks like it may be a MySQL/ODBC issue: http://bugs.mysql.com/bug.php?id=27632.

Perhaps switching to the MySQL Data Provider may help?

Randy Levy
Enterprise Library support engineer
Support How-to
Dec 4, 2013 at 5:12 AM
Hi,thanks for your solution........I had tried it separately with enterprise library itself before this post and worked perfectly with some other changes in cmd and parameters...

And what our issue is we have to create generic database(i-e it may be MYSQL,SQL SERVER,Oracle,etc) using EnterPrise Library..And we have Stored procedures which has input and output parameters...

We had found solution for oracle and SQL Server with AddInParameter and AddOutParameter and works nicely.................

But with Mysql only We not able to get it done.....If u have any solution suggest me and also we are creating the Database for Mysql with DataSource created with ODBC driver.......Thank you...............