C# .NET代码中的数据库错误

C# .NET代码中的数据库错误,c#,.net,function,stored-procedures,C#,.net,Function,Stored Procedures,我得到一个错误,如下所示:- 过程或函数“GetDetails”需要参数“@Number”,该参数 没有供应 调试后,我发现函数正在获取值。但我不知道如何纠正这个错误。我无法理解如何为“@”参数提供值 请用简单语言提供帮助您需要将@Number参数添加到命令中并设置值 下面是一个使用取自MSDN的参数执行存储过程的示例 static void GetSalesByCategory(string connectionString, string categoryName) { u

我得到一个错误,如下所示:-

过程或函数“GetDetails”需要参数“@Number”,该参数 没有供应

调试后,我发现函数正在获取值。但我不知道如何纠正这个错误。我无法理解如何为“@”参数提供值


请用简单语言提供帮助

您需要将@Number参数添加到命令中并设置值

下面是一个使用取自MSDN的参数执行存储过程的示例

static void GetSalesByCategory(string connectionString, 
    string categoryName)
{
    using (SqlConnection connection = new SqlConnection(connectionString))
    {
        // Create the command and set its properties.
        SqlCommand command = new SqlCommand();
        command.Connection = connection;
        command.CommandText = "SalesByCategory";
        command.CommandType = CommandType.StoredProcedure;

        // Add the input parameter and set its properties.
        SqlParameter parameter = new SqlParameter();
        parameter.ParameterName = "@CategoryName";
        parameter.SqlDbType = SqlDbType.NVarChar;
        parameter.Direction = ParameterDirection.Input;
        parameter.Value = categoryName;

        // Add the parameter to the Parameters collection. 
        command.Parameters.Add(parameter);

        // Open the connection and execute the reader.
        connection.Open();
        SqlDataReader reader = command.ExecuteReader();

        if (reader.HasRows)
        {
            while (reader.Read())
            {
                Console.WriteLine("{0}: {1:C}", reader[0], reader[1]);
            }
        }
        else
        {
            Console.WriteLine("No rows found.");
        }
        reader.Close();
    }
}

您必须显示一些代码。您如何调用该过程?能否同时显示您的工作?需要查看代码。如果您没有在代码中传递
@Number
参数,最好发布您的c代码