我正在研究UWP(秋季创作者更新),尝试ExecuteReader()
后我遇到两个例外。
这是我的代码:
MySqlConnection conn = Util.GetConnection("Server=localhost;Port=3306;Database=sample;Uid=root;Pwd=;CharSet=utf8;SslMode=None;");
conn.Open();
string Command = "SELECT id, role FROM tblUsers WHERE username = @user AND password = @pass";
MySqlCommand cmd = new MySqlCommand(Command, conn);
cmd.CommandType = CommandType.Text;
// handle username and password
cmd.Parameters.AddWithValue("@user", UserName);
cmd.Parameters.AddWithValue("@pass", Password);
cmd.Prepare();
MySqlDataReader reader = cmd.ExecuteReader(); // <-- throws an exception.
reader.Read();
...
检查查询本身和连接字符串,它们都很好。我得到的例外是:
Exception thrown: 'System.ArgumentException' in System.Private.CoreLib.ni.dll
Exception thrown: 'System.ArgumentOutOfRangeException' in System.Private.CoreLib.ni.dll
CreateCommand()
我可能需要async scanBarcode(){
const results = await this.barcode.scan();
this.resultsUI = await this.barcode.scan();
console.log(results);
}
,但我仍然有例外。