The stored procedure returns one value:
ALTER PROCEDURE [dbo].[spCaller]
AS
BEGIN
DECLARE @URL nvarchar(255);
EXECUTE spBuscarUrl 'MIREX-2017-00001', @url = @URL OUTPUT;
SELECT @URL
END
When I'm trying to show the value using ASP.NET, I get an error:
Procedure spCaller has no parameters and arguments were supplied
This is my C# code:
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);
}