//Multiple tables, multiple rows and multiple columns foreach (DataTable dt in YourDataset.Tables) //traverse all datatable { foreach (DataRow dr in dt.Rows) ///traverse all rows foreach (DataColumn dc in dt.Columns ) //Loop through all columns Console.WriteLine("{0}, {1}, {2}", dt.TableName, dc.ColumnName, dr[dc]); //Table name, column name, cell data } 2. // Traverse a table with multiple rows and columns foreach(DataRow mDr in dataSet.Tables[0].Rows ) { foreach(DataColumn mDc in dataSet.Tables[0].Columns) { Console.WriteLine(mDr[mDc] .ToString()); } } 3. //Traverse a table with multiple rows and one column foreach(DataRow row in DataSet1.Tables[0].Rows) { Console.WriteLine(row[0].ToString()); } 4. //One row and one column ds.Tables[0].Rows[0]["field "]
How to query the data in the dataset in C#, take each column of a row of data and put it in the textbox
Guess you like
Origin blog.csdn.net/u010655348/article/details/52972780
Recommended
Ranking