OLE Database connection a loop through row C#.NET


// set up the connection
OleDbConnection myConn = new OleDbConnection ( 
   "Provider=Microsoft.Jet.OleDb.4.0; Data Source=" + 
   Server.MapPath ( "~/shared/data/dbtutor.mdb" ) );

// set up the query
OleDbDataAdapter myCmd = new OleDbDataAdapter ( 
   "select * from Products", myConn );

// initialize dataset object
DataSet myData = new DataSet ( );
// fill with query results
myCmd.Fill ( myData, "Products" );

// display dataset contents
foreach ( DataTable table in myData.Tables ) {
   foreach ( DataRow row in table.Rows ) {
      foreach ( DataColumn col in table.Columns ) {
         Response.Write ( row [ col ].ToString ( ) );
      }
   }
}