【问题标题】:How to call an Output Parameter from a Mysql stored procedure in ASP.NET如何从 ASP.NET 中的 Mysql 存储过程调用输出参数
【发布时间】:2019-07-28 13:00:16
【问题描述】:

我在将输出参数从 Mysql 存储过程返回到 ASP.NET 变量时遇到问题。 我只想在 ASP 中使用 ligne 代码来获取该参数! 谢谢

【问题讨论】:

标签: c# mysql asp.net phpmyadmin


【解决方案1】:

假设有一个名为“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;

【讨论】:

  • 我怀疑由于,代码无法按原样编译。
  • 谢谢先生,我试试看:)
  • 哦,太好了 :) 非常感谢您的帮助和支持!
猜你喜欢
  • 2018-02-27
  • 1970-01-01
  • 2019-08-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多