前台代码:
         string kssj = TextBox2.Text;
        string jssj = TextBox4.Text;
        SqlDataSource1.ConnectionString = "Data Source=LJ-PC\\SQLEXPRESS;Initial Catalog=StudyRoom;Integrated Security=True";
        SqlDataSource1.SelectCommandType = SqlDataSourceCommandType.StoredProcedure;
        SqlDataSource1.SelectCommand = "datasum_proc";
        SqlDataSource1.SelectParameters.Add("@p_kssj", TypeCode.String, kssj);
        SqlDataSource1.SelectParameters.Add("@p_jssj", TypeCode.String, jssj);
        GridView1.DataSource = SqlDataSource1;
        SqlDataSource1.DataBind();
        GridView1.DataBind();数据库存储过程:
create proc datasum_proc
@p_kssj varchar(10),
@p_jssj varchar(10)asselect * from table where kssj between @p_kssj and @p_jssjreturn 0运行vs2005下该页面的时候 一直提示  未提供参数 @p_kssj 

解决方案 »

  1.   


    SqlDataSource1.DataBind();
    GridView1.DataSource = SqlDataSource1;换下顺序或者
    SqlConnection connection = new SqlConnection("Data Source=LJ-PC\\SQLEXPRESS;Initial Catalog=StudyRoom;Integrated Security=True");
    connection.Open();
    SqlCommand command = new SqlCommand("datasum_proc", connection);
    command.CommandType = CommandType.StoredProcedure;
    command.Parameters.AddWithValue("@p_kssj", kssj);  
    command.Parameters.AddWithValue("@p_jssj", jssj);  
    SqlDataReader reader = command.ExecuteReader();
    GridView1.DataSource = reader ;
    GridView1.DataBind();