The use of OleDbCommand related action classes requires the introduction of SYSTEM.DATA.OLEDB namespaces.
Verify that the connection and command usage is correct by connecting to the Access database with a password and reading the data in it and placing it in the table.
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Web;
Using System.Web.UI;
Using System.Web.UI.WebControls;
Using System.Data.OleDb; Public partial class _default:system.web.ui.page {protected void Page_Load (object sender, EventArgs e) {//Database connections, capturing of recordsets//Note change path String sqlconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = E:/pro/web/access_test/app_dat A/northwind.mdb;
Jet oledb:database password=111111 ";
OleDbConnection myconnection = new OleDbConnection (sqlconn);
Myconnection.open ();
OleDbCommand mycommand = new OleDbCommand ("SELECT * from Shippers", myconnection);
OleDbDataReader myreader;
myreader = Mycommand.executereader ();
Read Recordset Response.Write ("<table border=1 cellspacing=0 cellpadding=2>");
Response.Write ("<tr bgcolor= #DAB4B4 >");
for (int i = 0; i < Myreader.fieldcount i++) Response.Write ("<td>" + myreader.getname (i) + "</td>"); Response.Write ("</tR> ");
while (Myreader.read ()) {Response.Write ("<tr>"); for (int i = 0; i < Myreader.fieldcount i++) Response.Write ("<td>" + myreader[i).
ToString () + "</td>");
Response.Write ("</tr>");
} Response.Write ("</table>");
Close recordset and connect Myreader.close ();
Myconnection.close (); }
}
The effect chart is as follows:
The full project file has been uploaded.