我在将输出参数从 Mysql 存储过程返回到 ASP.NET 变量时遇到问题。我只想在 ASP 中使用 ligne 代码来获取该参数!谢谢
拉丁的传说
浏览 100回答 1
1回答
慕田峪7331174
假设有一个名为“MyOutParam”的参数,它是outputMySQL 存储过程的一种参数类型。在这种情况下,你需要做的是:// here goes the logic of instantiating the command for a stored procedure// cmd is the reference variable containing instance of SQLCommandcmd.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 executedvar outParamValue = cmd.Parameters[“MyOutParam”].Value;