请问怎么一行一行的遍历dataset啊 如题 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 DataSet不能一行一行的遍历吧?顶多能遍历DataTable吧? foreach( DataTable table in dataSetName.Tables ) { foreach( DataRow row in table.Rows ) { ........ } } 我有一个dataset,"ds",怎么取它的datatable啊 foreach( DataTable table in dataSetName.Tables ){ foreach( DataRow row in table.Rows ) { foreach( DataColumn col in row.Columns ) { string str = col.ToString(); } }} ds..Tables[0] //第一个datatable 看楼上的回帖。DataSet只包含数据视图,所以只能遍历数据视图 ds.Tables[0] //第一个datatableds.Tables[1] //第二个datatable foreach(DataRow row in dset.Tables[表名].Rows){} foreach(DataRow row in dset.Tables[表名].Rows){} 给个例子给你,我就是这样做的 try { Cursor.Current = ApplicationLog.AppCursor; DataSet deptDS = SystemManageBF.GetChildDeptByDeptID(ApplicationLog.AccessAreaID); DeptID = new string[deptDS.Tables[0].DefaultView.Count]; DataView dvTree = new DataView(deptDS.Tables[0]); foreach (DataRowView Row in dvTree) { int pos = cboDept.Items.Add(Row["DEPT_NAME"].ToString()); DeptID[pos - 1] = Row["DEPT_ID"].ToString(); } if (deptDS.Tables[0].DefaultView.Count > 0) cboDept.SelectedIndex = 0; Cursor.Current = Cursors.Default; } catch (Exception ex) { Cursor.Current = Cursors.Default; MessageBox.Show(ex.Message, "加载部门错误", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } Response.Cookies.Add()和方法Response.AppendCookie()有什么区别? ADO.NET事务与存储过程事务 关闭一个窗口 求C#源码格式化工具! comboBox控件问题? 如何获得粘贴内容?? 用C#写的.dll文件能够在VB6.0中引用吗? 装配中的脑袋等大侠请进....,对于一个集合属性,怎样在编辑完集合中的对象后,自动在InitializeComponent中new出对象,并且添加到集合属性中 请高手赐教:关于struct的问题(C#) 如何在C#设计的登陆页面的文本框中输入数字 c# debug的问题 新手上路!请求高手帮忙。。。。。
{
foreach( DataRow row in table.Rows )
{
........
}
}
{
foreach( DataRow row in table.Rows )
{
foreach( DataColumn col in row.Columns )
{
string str = col.ToString();
}
}
}
ds.Tables[1] //第二个datatable
{
}
{
}
try
{
Cursor.Current = ApplicationLog.AppCursor;
DataSet deptDS = SystemManageBF.GetChildDeptByDeptID(ApplicationLog.AccessAreaID);
DeptID = new string[deptDS.Tables[0].DefaultView.Count];
DataView dvTree = new DataView(deptDS.Tables[0]);
foreach (DataRowView Row in dvTree)
{
int pos = cboDept.Items.Add(Row["DEPT_NAME"].ToString());
DeptID[pos - 1] = Row["DEPT_ID"].ToString();
}
if (deptDS.Tables[0].DefaultView.Count > 0)
cboDept.SelectedIndex = 0;
Cursor.Current = Cursors.Default;
}
catch (Exception ex)
{
Cursor.Current = Cursors.Default;
MessageBox.Show(ex.Message, "加载部门错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
this.Close();
}