我想知道如何使用 C# 获取查询的记录计数。
这是我使用的代码..
MySqlDataReader recordset = null;
query = new MySqlCommand("SELECT * FROM test ORDER BY type_ID ASC", this.conn);
recordset = query.ExecuteReader();
while (recordset.Read())
{
result.Add(recordset["type_ID"].ToString());
}
return result;
我当时用的是SELECT COUNT(*)
并期望int
被退回。您可能需要它来获取可用值:
mysqlint = int.Parse(query.ExecuteScalar().ToString());
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)