首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

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

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

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(); 

热点排行