算了,那就换一种吧
怎样将SqlDataReader 对象赋给DataGrid,这应该简单吧!
即DataGrid1.DataSource 与 reader

解决方案 »

  1.   

    reader 是一行记录,这样没必要使用DataGrid,
    如果要使用DataGrid,那么就使用Dataset ,方法如下 :
    首先取得数据,放到DataGrid里System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection("server=localhost;database=northWind;uid=sa;password=110");
    conn.Open();
    System.Data.SqlClient.SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter("select * from student",conn);
    dt = new System.Data.DataSet();
    da.Fill(dt,"student");然后绑定数据集和DataGrid
    DataGrid.SetDataBinding(dt,"student");
      

  2.   

    我现在做的就是一定要用SqlDataReader 
    对于DataSet我也想过,实现起来不难
      

  3.   

    this.textBox1.Text = reader.GetString(0);
      

  4.   

    朋友
    当你用SqlDataReader 得 话 不要忘记 用while{}
    while
    {
      this.textBox1.Text=reader[0].ToString();
    }
      

  5.   

    朋友
    当你用SqlDataReader 得 话 不要忘记 用while{}
    while
    {
      this.textBox1.Text=reader[0].ToString();
    }