ionline - 类,字符串 myname
private static void SetOnlineStatus(PacketHeader header, Connection connection, ionline message)
{
Console.WriteLine("Check online: " + message.myname);
MySqlCommand mycmd = new MySqlCommand();
mycmd.CommandText = "SELECT * FROM users WHERE username = ?user";
mycmd.Connection = mconnection;
mycmd.Parameters.AddWithValue("user", message.myname);
MySqlDataReader Reader = mycmd.ExecuteReader();
while (Reader.Read())
{
Console.WriteLine("Check online: " + message.myname+" "+GetDBString("username",Reader));
MySqlCommand mycmd2 = new MySqlCommand();
mycmd2.CommandText = "UPDATE users SET online = 0 WHERE userid = @user2";
mycmd2.Parameters.AddWithValue("@user2", Reader.GetInt32("userid"));
mycmd2.Connection = mconnection;
Console.WriteLine(mycmd2.ExecuteNonQuery().ToString());
}
}
Mysql 请求“mycmd2”未执行。我的查询中有什么不正确的?