存储过程返回一个值:过程没有参数和论点提供3
ALTER PROCEDURE [dbo].[spCaller]
AS
BEGIN
DECLARE @URL nvarchar(255);
EXECUTE spBuscarUrl 'MIREX-2017-00001', @url = @URL OUTPUT;
SELECT @URL
END
当我试图表现出使用ASP.NET的价值,我得到一个错误:
Procedure spCaller has no parameters and arguments were supplied
这是我的C#代码:
try
{
string s = System.Configuration.ConfigurationManager.ConnectionStrings["dba"].ConnectionString;
SqlConnection conexion = new SqlConnection(s);
conexion.Open();
using (SqlCommand cmd = new SqlCommand("spCaller",conexion))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@URL", SqlDbType.NVarChar).Value = Label1.Text.Trim();
object o = cmd.ExecuteScalar();
if(o != null)
{
string id = o.ToString();
lblTitulo.Text = "Completed";
}
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
的可能的复制[如何使用OUTPUT参数的存储过程(https://stackoverflow.com/questions/7770924/how-to-use-output - 参数存储过程) – mjwills
请包含'spBuscarUrl'的源代码。 – mjwills