【发布时间】:2019-07-28 13:00:16
【问题描述】:
我在将输出参数从 Mysql 存储过程返回到 ASP.NET 变量时遇到问题。 我只想在 ASP 中使用 ligne 代码来获取该参数! 谢谢
【问题讨论】:
-
如果你能在minimal reproducible example 上分享你目前的进展,那就太棒了。
标签: c# mysql asp.net phpmyadmin
我在将输出参数从 Mysql 存储过程返回到 ASP.NET 变量时遇到问题。 我只想在 ASP 中使用 ligne 代码来获取该参数! 谢谢
【问题讨论】:
标签: c# mysql asp.net phpmyadmin
假设有一个名为“MyOutParam”的参数,它是您的 MySQL 存储过程的 output 类型的参数。在这种情况下,您需要做的是:
// 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;
【讨论】:
”,代码无法按原样编译。