How to populate data from access database into asp.net table control. plz help me out. waiting for quick response.
thanks in advance..

Dani AI

Generated

A concise, practical plan that builds on this thread: wanted to fill an ASP.NET Table control from an Access DB and correctly pointed at the need for an OLE DB connection. The usual, reliable workflow is: keep the .mdb/.accdb file in App_Data, store the connection string in web.config, use System.Data.OleDb to fill a DataTable, then either bind that DataTable to a GridView or programmatically create TableRows/TableCells for an ASP.NET Table. Choose the right provider (Jet vs ACE) for your file and hosting bitness.

Example: fill a DataTable and bind to a GridView (C#):

using System.Data;
using System.Data.OleDb;
using System.Configuration;

var connStr = ConfigurationManager.ConnectionStrings["MyAccess"].ConnectionString;
using (var conn = new OleDbConnection(connStr))
using (var da = new OleDbDataAdapter("SELECT * FROM MyTable", conn))
{
    var dt = new DataTable();
    da.Fill(dt);
    GridView1.DataSource = dt;
    GridView1.DataBind();
}

If you must use an <asp:Table>, build rows from the DataTable:

Table1.Rows.Clear();
foreach (DataRow r in dt.Rows)
{
    var tr = new TableRow();
    foreach (DataColumn c in dt.Columns)
        tr.Cells.Add(new TableCell { Text = r[c].ToString() });
    Table1.Rows.Add(tr);
}

Troubleshooting and cautions: the Jet provider is 32-bit only; on 64-bit hosts use ACE or enable 32-bit mode for the app pool. Ensure IIS has file permissions on App_Data. Parameterize queries to avoid injection and data errors. Access is fine for low-traffic sites; for scalability and concurrency, consider SQL Server Express or a managed database.

Recommended Answers

All 2 Replies

conecction _string="provider=microsoft.jet.oledb.4.0;
data source=C:\vb\..\mydb.mdb"

and every thing else is the same.

thanks a lot

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.