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,491 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

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…
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
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…

821 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