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();