[英]How to call an Output Parameter from a Mysql stored procedure in ASP.NET
I am having a problem returning an output parameter from a Mysql stored procedure into a ASP.NET Variable. 我在将Mysql存储过程的输出参数返回到ASP.NET变量时遇到问题。 I just want the ligne code to use in ASP to get that Parameter ! 我只希望ligne代码在ASP中使用以获取该参数! Thank you 谢谢
let's suppose that there is a parameter named 'MyOutParam' which is an output
type of parameter for your MySQL stored procedure. 让我们假设有一个名为“ MyOutParam”的参数,它是MySQL存储过程的参数的output
类型。 In that case what you will have to do is: 在这种情况下,您将要做的是:
// here goes the logic of instantiating the command for a stored procedure
// cmd is the reference variable containing instance of SQLCommand
cmd.Parameters.Add(new MySqlParameter(“MyOutParam”, MySqlDbType.VarChar));
cmd.Parameters[“MyOutParam”].Direction = ParameterDirection.Output; // this is how we declare the parameter to be of 'output' type.
cmd.ExecuteNonQuery();
// this is how we can get the value in the output parameter after stored proc has executed
var outParamValue = cmd.Parameters[“MyOutParam”].Value;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.