复制代码 代码如下:
protected void Page_Load(object sender, EventArgs e)
{
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("db.mdb");
conn.Open();
OleDbCommand cmd = new OleDbCommand("select * from [article]",conn);
OleDbDataReader dr = null;
dr = cmd.ExecuteReader();
while (dr.Read()) {
Response.Write(dr["art_title"].ToString() + "<br>");
Response.Write(dr["art_author"].ToString() + "<br>");
}
dr.Close();
conn.Close();
}
复制代码 代码如下:
<asp:Table runat="server">
</asp:Table>
复制代码 代码如下:
TableRow tr;
TableCell tc;
while (dr.Read()) {
tr= new TableRow();
tc = new TableCell();
tc.Text = dr["art_title"].ToString();
tr.Controls.Add(tc);
tc = new TableCell();
tc.Text = dr["art_author"].ToString();
tr.Controls.Add(tc);
Table1.Controls.Add(tr);
}
新闻热点
疑难解答
图片精选