OleDbConnection cn = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=C:\\tblImp\\db1.mdb");
cn.Open();
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter("select * from tblImp", cn);
da.Fill(ds, "tblImp");
tablecontrol.datasource() = ds.Tables[0];
tablecontrol.DataBind();

table is not populated with data from access database.
help me plz.

Dani AI

Generated

A common root cause in this thread is treating an ASP.NET Table control like a data-bound grid. The server-side Table (System.Web.UI.WebControls.Table) does not generate rows from a DataTable automatically the way GridView or Repeater do. As suggested, first confirm the database call actually opens and returns rows; if the query returns data but the page still shows an empty table, the control type is likely the issue.

Two practical options:

  • Use a GridView or other data-bound control to bind the DataTable directly (automatic row/column rendering). See the GridView documentation for details.
  • If the Table control must be used, create TableRow and TableCell objects from the DataTable and add them to the Table.Rows collection. Example pattern:
aspTable.Rows.Clear();
foreach (DataRow r in dataTable.Rows)
{
    TableRow tr = new TableRow();
    foreach (DataColumn c in dataTable.Columns)
    {
        TableCell tc = new TableCell { Text = r[c].ToString() };
        tr.Cells.Add(tc);
    }
    aspTable.Rows.Add(tr);
}

Other troubleshooting items: confirm the server-side control has runat="server" and an ID so it is reachable from code-behind; bind at the correct page lifecycle point (e.g., Page_Load with appropriate postback checks); ensure the ASP.NET process identity has filesystem access to the .mdb file; and on modern 64-bit hosts note that the old Jet OLEDB provider is 32-bit only—use the ACE provider or run the app pool in 32-bit mode. See the Table control docs, GridView docs, and the Microsoft note on Jet/64-bit for more details.

Table control docs
GridView docs

first, run your program in debug mode.

You need to insert a breakpoint at cn.Open and F11 through step by step.

Why? To see if the connection has even been made properly. I dont seen an InitialCatalog value for your connection string. This might need addending as well.

hi,
i am a beginner in asp.net. wat to do to populate table control from access database. above code is not workin. problem is in bindin data with table control. how to bind data to table control.
thanks for help.

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.