多个结果集的查询(使用table显示多个结果集)
来源:互联网 发布:知乎经典钓鱼贴 编辑:程序博客网 时间:2024/05/22 02:07
前台:
<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());
}
}
}
}
- 多个结果集的查询(使用table显示多个结果集)
- HQL查询多个对象,结果集
- 用do while实现多个结果集的查询
- 从数据库中查询一个结果集和多个结果集的方法
- sql2005使用多个结果集
- 输出多个结果集
- 多个活动的结果集(MARS)
- 多个结果集ResultSet的问题
- 多个活动的结果集 (MARS)
- 多个select查询结果集纵向合并
- SQL为查询的结果加上序号(ROW_NUMBER) 合并多个查询结果
- Oracle 多个查询语句结果合并
- 多个查询结果合并问题
- Oracle 多个查询结果的交集、差集和并集
- Java对oracle查询多个结果集集合的存储
- left join连接2个查询结果集的用法
- oracle 显示多个分组的统计结果 GROUPING SETS
- asp.net 中使用1个DataGrid控件,显示不同表查询的结果的方法。
- 计算机中的数值数据表示
- Hangover
- 相关学习---链接
- StreamReader与StreamWriter乱码问题
- 返回最新添加的学生的自动编号Id
- 多个结果集的查询(使用table显示多个结果集)
- 小心C++的自动类型转换陷阱
- Ajax提交
- ADO.net小结
- NYOJ - A Famous Music Composer
- 自己写SQLHELPER.CS,其中的方法有ExecuteNonQuery(xxx),ExectueScalar(xxx),ExectueReader,executeDataTble
- 数据的插入、删除、修改,用SQLHelper类
- ArrayList实现
- 宽带上网手册