我无法弄清楚造成这种异常的原因。我来自VB.NET背景,而C#让我真的很难过。有人可以对此有所了解吗?
using (MySqlConnection connection = new MySqlConnection("server=server;uid=uid;pwd=pwd;database=db;SslMode=None"))
{
connection.Open();
MySqlCommand getCommand = connection.CreateCommand();
getCommand.Parameters.AddWithValue("@MyId", MyId);
getCommand.CommandText = "SELECT COUNT(*) FROM PhoneTag WHERE MyId = @MyId";
int userCount = (int)getCommand.ExecuteScalar();
}
答案 0 :(得分:0)
看起来我应该使用ExecuteNonQuery()