gpt4 book ai didi

c# - 如何从 ASP.NET 中的 Mysql 存储过程调用输出参数

转载 作者:行者123 更新时间:2023-11-29 09:37:46 24 4
gpt4 key购买 nike

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

最佳答案

假设有一个名为“MyOutParam”的参数,它是 MySQL 存储过程的输出类型参数。在这种情况下,您需要做的是:

// 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;

关于c# - 如何从 ASP.NET 中的 Mysql 存储过程调用输出参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57241142/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com