Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 程序或功能';选择1#u customer';应为参数'@Customerid';,这是没有提供的_C#_Sql_Asp.net - Fatal编程技术网

C# 程序或功能';选择1#u customer';应为参数'@Customerid';,这是没有提供的

C# 程序或功能';选择1#u customer';应为参数'@Customerid';,这是没有提供的,c#,sql,asp.net,C#,Sql,Asp.net,这是我的代码: protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { mytable = new DataTable(); mytable.Columns.Add("Customerid"); mytable.Columns.Add("Customername");

这是我的代码:

protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            mytable = new DataTable();
            mytable.Columns.Add("Customerid");
            mytable.Columns.Add("Customername");
            mytable.Columns.Add("Contactname");
            mytable.Columns.Add("Address");
            mytable.Columns.Add("Mobile");

            GridView1.DataSource = mytable;
            GridView1.DataBind();
            string constr = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
            SqlConnection con = new SqlConnection(constr);
            //SqlCommand cmd = new SqlCommand("select * from Table_3", con);


            SqlCommand cmd = new SqlCommand("select1_customer", con);
            cmd.CommandType = CommandType.StoredProcedure;              
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            sda.Fill(mytable);
            GridView1.DataSource = mytable;
            GridView1.DataBind();
        }
    }
过程或函数“select1\u customer”需要未提供的参数“@Customerid”。这是我的错误

你的名字不见了

cmd.Parameters.AddWithValue("@Customerid", required value);
试试看


您尚未传递select1的输入参数\u Customer我已从sp传递了spremove参数中的参数,如果您只需要select查询,如果您想要在其中传递用于tut检查的筛选器或逻辑参数aspsnippets网站可能与bt重复,我仅选择sp以查看网格表,即使您的存储过程没有“选择”,它可能是使用其中的“@CustomerID”参数创建的。因此,在C#中,假设您将值传递给该过程。或者,您可以通过根据参数的数据类型将默认值设置为存储过程来对其进行更改,如@Customerid=''(若为varchar)
SqlCommand cmd = new SqlCommand("select1_customer", con);
cmd.CommandType = CommandType.StoredProcedure; 
cmd.Parameters.AddWithValue("@Customerid", "value_for_CustomerID");             
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(mytable);
GridView1.DataSource = mytable;
GridView1.DataBind();