using C# How to open an MS Access database and  import the data into a gridview

Posted on 2014-01-14
Last Modified: 2014-01-16
Can I get data from an Access Database and import that data into an ASP.NET gridview?
If so, please provide a detialed C#/ code example.
Question by:newjeep19
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2

Accepted Solution

fredvr666 earned 500 total points
ID: 39780220
Like this:
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Data;
namespace WebApplication2
    public partial class WebForm1 : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)
    private void OpenAccessTables()
        //"Jet OLEDB:Database Password=;" +
        string AccessConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
                                         "Data Source=C:\\test.mdb; " +
                                         ";Persist Security Info=False";
        OleDbConnection conAccess = new OleDbConnection();
        conAccess.ConnectionString = AccessConnString;
        //open the connection to the Access database
        OleDbCommand cmd = new OleDbCommand("SELECT * FROM tbluren", conAccess);
        cmd.CommandType = CommandType.Text;
        OleDbDataAdapter data = new OleDbDataAdapter(cmd);
        DataTable uren = new DataTable();
        this.GridView1.DataSource = uren;


Author Comment

ID: 39780815
Thank you for the example....I am using file upload and getting th path to the access db then I need to open that data from the access db in an gridview table. From the gridview table I need to then update the data to a SQL db table.

Expert Comment

ID: 39781607
newjeep this is a new question :-)

Author Comment

ID: 39786165
OK I will close the request then

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question