protected void Page_Load(object sender, EventArgs e)
{
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + Server.MapPath("person.mdb");
conn.Open();
string strSQL = "select * from grade";
OleDbCommand Comm = new OleDbCommand(strSQL, conn);
OleDbDataReader dr = Comm.ExecuteReader();
string html = "<table border=1>";
html += "<tr>";
html += "<td><b>学号</b></td>";
html += "<td><b>姓名</b></td>";
html += "<td><b>数学</b></td>";
html += "</tr>";
try
{
while (dr.Read())
{
html += "<tr>";
html += "<td>" + dr["学号"].ToString() + "</td>";
html += "<td>" + dr["姓名"].ToString() + "</td>";
html += "<td>" + dr["数学"].ToString() + "</td>";
html += "</tr>";
}
html += "</table>";
}
finally
{
dr.Close();
conn.Close();
}
Response.Write(html);
}
{
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + Server.MapPath("person.mdb");
conn.Open();
string strSQL = "select * from grade";
OleDbCommand Comm = new OleDbCommand(strSQL, conn);
OleDbDataReader dr = Comm.ExecuteReader();
string html = "<table border=1>";
html += "<tr>";
html += "<td><b>学号</b></td>";
html += "<td><b>姓名</b></td>";
html += "<td><b>数学</b></td>";
html += "</tr>";
try
{
while (dr.Read())
{
html += "<tr>";
html += "<td>" + dr["学号"].ToString() + "</td>";
html += "<td>" + dr["姓名"].ToString() + "</td>";
html += "<td>" + dr["数学"].ToString() + "</td>";
html += "</tr>";
}
html += "</table>";
}
finally
{
dr.Close();
conn.Close();
}
Response.Write(html);
}