如何修复错误KeyNotFoundException The given key was not present in the dictionary.
与C#unity中的localhost连接
我不知道ExecuteReader
和MySqlDataReader
中的错误原因是什么。
private MySqlCommand cmd;
private MySqlDataReader rmd;
void getdata(MySqlConnection _conn)
{
string sql = "SELECT * FROM user";
cmd = new MySqlCommand(sql, _conn);
rmd = cmd.ExecuteReader();
while (rmd.Read())
{
string d1 = (string)rmd["username"];
string d2 = (string)rmd["country"];
Debug.Log(d1);
Debug.Log(d2);
}
}
以下是我的数据库设置
和错误消息