作者:兔子是不常吃萝卜的 | 来源:互联网 | 2022-12-09 20:10
1> AAAbbbCCCddd..:
它很简单
// Always call Read before accessing data.
// Advances the MySqlDataReader to the next record.
// returns true if it finds a record
while (dataReader.Read())
{
// depending on your query
Console.WriteLine(myReader.GetInt32(0) + ", " + myReader.GetString(1));
}
如果你想要行数,你总是可以使用一个DataTable
甚至只是在while循环中使用一个计数.DataTable示例:
DataTable dt = new DataTable();
dt.Load(reader);
Console.WriteLine("Rows returned : " + dt.Rows.Count);
foreach(DataRow dr in dt.Rows)
{
Console.WriteLine(dr["SomeResultingColumn"]);
}