SqlDataAdapter da=new SqlDataAdapter();
da.Fill(mytable);
mytable中有两列,id,name.
我现在想取出name列的所有值,怎么做啊 ?
或者取出id列的第5行的值,怎么做呢?
望高手赐教!!!

解决方案 »

  1.   

    sql语句只选name就可以了呀这个就是第五行的值
    mytable.Tables[0].Rows["id"].Cells[4]
      

  2.   

    name列的所有值:
    ArrayList nameList = new ArrayList();
    for(int i=0;i<mytable.Rows.Count;i++)
        nameList.Add(mytable.Rows[i]["name"].ToString());id列的第5行的值:
    mytable.Rows[5]["id"].ToString();
      

  3.   

    sorry.
    id列的第5行的值应该是:
    mytable.Rows[4]["id"].ToString();
      

  4.   

    可它提示:
    与“System.Data.DataRowCollection.this[int]”最匹配的重载方法具有一些无效参数
      

  5.   

    mytable.Tables[0].Rows["id"].Cells[4]
                             ^ 这肯定不能这么用。