ado.net如何将记录集中第一张表ds.Tables[0]直接导入字符串数组string[] str中。类似形式为:string[] str = ds.Tables[0].....

解决方案 »

  1.   


    string[] str = new string[ds.Tables[0].Rows.Count];
    for(int i = 0; i < str.Length; i++)
    {
        str[i] = ds.Tables[0].Rows[i][0];//不知道你要哪一列,这里以每行第一列为例
    }
      

  2.   

    漏了
    str[i] = ds.Tables[0].Rows[i][0].ToString();
      

  3.   


                string[,] str = new string[dt.Rows.Count, dt.Columns.Count];
                for (int i = 0; i < dt.Rows.Count; i++)
                    for (int j = 0; j < dt.Columns.Count; j++)
                        str[i, j] = dt.Rows[i][j].ToString();
      

  4.   

    我的意思是不用循环,有没有类似的成员函数用一个语句就能实现。如我假想的:
    string[,] str = ds.Tables[0].直接导入数组;