Parameter must be declared during executeNonQuery in Connector.NET using mySql

时间:2015-06-15 14:34:29

标签: c# mysql

I'm using MySqlConnector to execute query in C# code. I have example procedure:

CREATE PROCEDURE RC_TEST
(
    ZIPCODE VARCHAR(7),
    INOUT SEARCH_VALUE VARCHAR(2)
)
BEGIN
    DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
    BEGIN
        SET @SWV_Error = 1;
    END;

SELECT TB_TABLE.SEARCH_VALUE INTO SEARCH_VALUE FROM TB_TABLE
WHERE TB_TABLE.ZIPCODE = ZIPCODE;

IF @SWV_ERROR <> 0 THEN
    SET SEARCH_VALUE = NULL
END IF;
END;

When I'm executing this procedure in MySql Workbench - everything is ok. But when I'm the same piece of code execute in C# code:

conn.Open();
var command = new MySqlCommand(script, conn);
command.ExecuteNonQuery();
conn.Close();

I got the error:

"Parameter '@SWV_Error' must be defined."

What am I doing wrong?

0 个答案:

没有答案