读书人

ado.net怎么将记录集中第一张表ds.Tab

发布时间: 2011-12-29 22:09:38 作者: rapoo

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


[解决办法]

C# code
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];//不知道你要哪一列,这里以每行第一列为例}
[解决办法]
C# code
            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(); 

读书人网 >C#

热点推荐