Hi
I am trying to retrieve the value of a stored procedure´s output parameter from .net using ODBC. I am aware that I could use the MySQL .net provider, but the hosting where I am planning to host my app only runs with the odbc driver.
I manage to execute the procedure but can´t retrieve the OUTPUT parameter value.
How can I get the output parameters value?? Thanks !!
Heres the stored procedure:
And heres my .net code:Code:DELIMITER $$ DROP PROCEDURE IF EXISTS `testProc` $$ CREATE PROCEDURE `testProc`(IN customName varchar(50), OUT customId int) BEGIN INSERT INTO testtable(customername) VALUES (customName); SELECT LAST_INSERT_ID() INTO customId; END $$ DELIMITER ;
Code:OdbcConnection connection = new OdbcConnection(ConfigurationManager.ConnectionStrings["cinlopesConnection"].ConnectionString); OdbcCommand command = new OdbcCommand(); command.Connection = connection; command.CommandType = CommandType.StoredProcedure; command.CommandText = "{CALL testProc(?,@werwer)}"; OdbcParameter inParameter = new OdbcParameter(); inParameter.ParameterName = "customName"; inParameter.Direction = ParameterDirection.Input; inParameter.OdbcType = OdbcType.VarChar; inParameter.Size = 50; inParameter.Value = "wrapperFromNET2"; command.Parameters.Add(inParameter); OdbcParameter outputParam = new OdbcParameter(); outputParam.ParameterName = "customId"; outputParam.Direction = ParameterDirection.Output; outputParam.OdbcType = OdbcType.Int; command.Parameters.Add(outputParam); connection.Open(); int result =(int)command.ExecuteNonQuery();


Reply With Quote