前台:
<body>
<form id="form1" runat="server">
<div>
<asp:Table ID="Table1" runat="server">
</asp:Table>
</div>
</form>
</body>
后台:
protected void Page_Load(object sender, EventArgs e)
{
string constr = "data source=.;initial catalog=MySchool;User ID=sa;Password=111111";
using (SqlConnection con = new SqlConnection(constr))
{
string sql = "select * from Student;select * from Class";
using (SqlCommand cmd = new SqlCommand(sql, con))
{
con.Open();
using (SqlDataReader reader = cmd.ExecuteReader())
{
do
{
if (reader.HasRows)
{
while (reader.Read())
{
TableRow trRow = new TableRow();
TableCell tcCell;
for (int i = 0; i < reader.FieldCount; i++)
{
tcCell = new TableCell();
tcCell.BorderStyle = BorderStyle.Solid;
tcCell.BorderWidth = 1;
tcCell.Text = reader.GetValue(i).ToString();
trRow.Cells.Add(tcCell);
}
Table1.Rows.Add(trRow);
}
}
} while (reader.NextResult());
}
}
}
}
<body>
<form id="form1" runat="server">
<div>
<asp:Table ID="Table1" runat="server">
</asp:Table>
</div>
</form>
</body>
后台:
protected void Page_Load(object sender, EventArgs e)
{
string constr = "data source=.;initial catalog=MySchool;User ID=sa;Password=111111";
using (SqlConnection con = new SqlConnection(constr))
{
string sql = "select * from Student;select * from Class";
using (SqlCommand cmd = new SqlCommand(sql, con))
{
con.Open();
using (SqlDataReader reader = cmd.ExecuteReader())
{
do
{
if (reader.HasRows)
{
while (reader.Read())
{
TableRow trRow = new TableRow();
TableCell tcCell;
for (int i = 0; i < reader.FieldCount; i++)
{
tcCell = new TableCell();
tcCell.BorderStyle = BorderStyle.Solid;
tcCell.BorderWidth = 1;
tcCell.Text = reader.GetValue(i).ToString();
trRow.Cells.Add(tcCell);
}
Table1.Rows.Add(trRow);
}
}
} while (reader.NextResult());
}
}
}
}
本文深入探讨了数据库管理系统的基本概念、数据模型、实体-关系模型、索引理论、事务管理、结构化查询语言和数据库备份等核心内容,提供了一套全面的数据管理解决方案。

被折叠的 条评论
为什么被折叠?



