Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-01-14
4
Medium Priority
?
1,653 Views
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#/ASP.net code example.
0
Comment
Question by:newjeep19
[X]
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
4 Comments
 
LVL 3

Accepted Solution

by:
fredvr666 earned 2000 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)
        {
            OpenAccessTables();
        }
       
    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
        conAccess.Open();
        OleDbCommand cmd = new OleDbCommand("SELECT * FROM tbluren", conAccess);
        cmd.CommandType = CommandType.Text;
        OleDbDataAdapter data = new OleDbDataAdapter(cmd);
        DataTable uren = new DataTable();
        data.Fill(uren);
        this.GridView1.DataSource = uren;
        this.GridView1.DataBind();


    }
  }
}
0
 

Author Comment

by:newjeep19
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 asp.net gridview table. From the gridview table I need to then update the data to a SQL db table.
0
 
LVL 3

Expert Comment

by:fredvr666
ID: 39781607
newjeep this is a new question :-)
0
 

Author Comment

by:newjeep19
ID: 39786165
OK I will close the request then
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

715 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