我正在为 iOS 应用程序使用 flex 4.5。我正在尝试制作登录屏幕。在这里,我附上了我的代码:
登录按钮的点击处理程序:
protected function btnlogin_clickHandler(event:MouseEvent):void
{
user();
}
调用此函数:
private function user():void
{
sqlConnection = new SQLConnection();
sqlConnection.open(File.applicationStorageDirectory.resolvePath("SchoolSeries.db"));
var stmt:SQLStatement = new SQLStatement();
stmt.sqlConnection = sqlConnection;
stmt.text = "select User_Name from USER_NEW where User_Password = :password"
stmt.parameters[":password"] = password.text ;
stmt.execute();
var result11:SQLResult = stmt.getResult();
DataModel.getInstance().connection = sqlConnection;
//statuslable1.text = (String(result11.data[0].User_Conform_Password));
if ((String(result11.data[0].User_Name)) == username.text)
{
//VerifyLogin();
navigator.pushView(SummaryView,{unm:username.text});
}
else
{
statuslabelpass.visible = false;
statuslabel1.visible = false;
statuslabel.visible =true;
statuslabel.text = "Username & Password do not match";
}
}
我的问题是我没有按照我想要的方式验证字段。如果我输入了正确的密码但输入了错误的用户名,那么只有我会收到类似“用户名和密码不匹配”的消息。但是,如果我输入了正确的用户名和错误的密码,则不会收到任何消息。
如果我编写另一个验证密码的函数,并通过单击按钮调用它,那么那个函数甚至还没有被调用。
private function passwrd():void
{
sqlConnection = new SQLConnection();
sqlConnection.open(File.applicationStorageDirectory.resolvePath("SchoolSeries.db"));
var stmt:SQLStatement = new SQLStatement();
stmt.sqlConnection = sqlConnection;
stmt.text = "select User_Password from USER_NEW where User_Name = :username"
stmt.parameters[":username"] = username.text ;
stmt.execute();
var result11:SQLResult = stmt.getResult();
DataModel.getInstance().connection = sqlConnection;
//statuslable1.text = (String(result11.data[0].User_Conform_Password));
if ((String(result11.data[0].User_Password)) == password.text)
{
navigator.pushView(SummaryView,{unm:username.text});
}
else
{
statuslabel.visible = false;
statuslabel1.visible = false;
statuslabelpass.visible =true;
statuslabelpass.text = "Username & Password do not match";
}
}
我应该怎么做才能验证 sqlite 数据库的两个字段?