我想知道如何使用 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());
关于c# - 用C#获取MySQL记录数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2807282/