ado一次输出多个结果集
string constr = "data source=.;initial catalog=TestSchool;user id=sa;password=7777777";
using(SqlConnection conn=new SqlConnection(constr))
{
string sql = "select * from MyStudents;select * from class";
using(SqlCommand cmd=new SqlCommand(sql,conn))
{
conn.Open();
using (SqlDataReader reader = cmd.ExecuteReader())
{
do
{
if (reader.HasRows)
{
while (reader.Read())
{
for (int i = 0; i < reader.FieldCount; i++)
{
Response.Write(reader.GetValue(i).ToString()+" ");
}
Response.Write("<br>");
}
}
}
while (reader.NextResult());
}
}
}
}
}
}