viet vo quoc

viet vo quoc

  • NA
  • 115
  • 105.5k

Can use dataset or datatable to contain the data from access databsase??

Nov 24 2011 9:18 AM
Hello Friend!!
i have a access database and i want to take data from that database ,so when i use sql database i use dataset or datatable to contain the data from sql database.For access database i find on the internet the code to connect and take data from access database.Like this:

OleDbConnection con;   // create connection
 OleDbCommand com;  // create command
 OleDbDataReader dr;  //Dataread for read data from database
 con = new OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0; Data Source = D:\\mydb.mdb");
 com = new OleDbCommand("Select * from Table1",con);
 con.Open();                                        // open the coinnection
 dr = com.ExecuteReader();

//now you can store into Gridview
GridView1.DataSource = dr;
 GridView.DataBind();
 con.Close();  //Close the connection

Can i use dataset or datatable to alter for datareader?? and if it can't.
The way to check every record in datareader by foreach?
Thanks so much!I'm beginner with access database!!

Answers (5)