for(int i=0;i<ds.Tables["B_BM"].Rows.Count;i++)
{
for(int j=0;j<ds.Tables["B_BM"].Columns.Count;j++)
{
MessageBox.Show(ds.Tables["B_BM"].Rows[i][j].ToString());
}
}
{
for(int j=0;j<ds.Tables["B_BM"].Columns.Count;j++)
{
MessageBox.Show(ds.Tables["B_BM"].Rows[i][j].ToString());
}
}
cmd.Fill(ds,"表1");
for (int i=0; i<ds.tables[0].rows.count; i++)
{
richTextBox1.Apptext(ds.Tables["mytable"].Rows[i]["列名"].ToString(););
}
例子:for(int i=0;i<DataGrid1.Items.Count;i++)
{
//楼宇
if ((DataGrid1.Items[i].Cells[4].Text.Trim()) != "")
{
string strlymc ="select distinct lymc from xxwt_ly where lybh = '"+ DataGrid1.Items[i].Cells[4].Text.Trim() +"'";
OleDbDataAdapter mycommand=new OleDbDataAdapter(strlymc,Conxxwgl);
DataSet ds = new DataSet();
mycommand.Fill(ds,ls_tablestr);
DataRowCollection myrows = ds.Tables[ls_tablestr].Rows;
for(int j=0;j<myrows.Count;j++)
{
DataGrid1.Items[i].Cells[4].Text = myrows[j]["lymc"].ToString().Trim();
}
}
}