各位高手帮我看看这段代码,我想调用存储过程,为什么运行后在GridView中不显示数据                conn.Open();
                DataSet ds = new DataSet();
                SqlDataAdapter da = new SqlDataAdapter();
                SqlCommand mycommand = new SqlCommand();
                mycommand.Connection = conn;
                mycommand.CommandText = "存储练习_2";
                mycommand.CommandType = CommandType.StoredProcedure;
                da.SelectCommand = mycommand;
                da.Fill(ds);
                this.GridView2.DataSource = ds.Tables[0];
                this.GridView2.DataBind();

解决方案 »

  1.   

    Fill之前漏了执行的函数,Execute
      

  2.   

    我加了个 mycommand.ExecuteNonQuery();还是没有显示呢,存储过程是没有问题的,SQL中能运行
    一直不知道这个错在哪里```不显示啊``
      

  3.   

    using(SqlConnection sqlconn = new SqlConnection(conn))
    {
          SqlCommand cmd = new SqlCommand("存储练习_2",conn);
           cmd.CommandType = CommandType.StoredProcedure;
          SqlDataAdapter dp = new SqlDataAdapter(cmd);
          DataSet ds = new DataSet();
          dp.Fill(ds);
           GridView1.DataSource = ds;
          GridView1.DataBind();
    }
    查询分析中执行