AspdotnetCodes.com
Search
Articles
Books
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
Questions & Answers
Tips & Tricks
 binding
Posted by komail on  4/7/2009 3:53:54 AM Category: ADO.NET
Add to my favorites
Email to friend
how to bind data from database through coding in ms access

Post Your Reply Post New Question

 Viewer's Reply
Use OleDbConnectionobject to connect MS Access Database
Answered By Moderator1 on 4/7/2009 11:36:37 AM
Try the below code sample, rest is same as SqlConnection object

using System.Data.OleDb;

In the Page_Load event write the below code

If (!IsPostBack)
{
OleDbConnection cn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\AccessDB\\SampleDB.mdb;User Id=sa;Password=abc;");


OleDbDataAdapter da = new OleDbDataAdapter("Select * from Customers", cn);
DataTable dt = new DataTable();
da.Fill(dt);
da.Dispose();
cn.Dispose();
GridView1.DataSource = dt;
GridView1.DataBind();
}
 
Post Your Reply If you still have problem, post it again under this reply for better response.

 
Sponsored by
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
Take Advantage of Oracle's 2 Day DBA Course
No Nonsense XML Web Development With PHP - Free 146 Page Preview!