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
1,517 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
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
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)
        {
            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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

828 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