WPF连接SQLServer数据库并判断永明和密码时都存在,若存在则跳转到下一个页面,否则弹出对话框,以下是我的代码,为什么不管用户名和密码对不对页面都会直接跳
--------------------编程问答-------------------- 错误已经找到,并改正了要将 while (reader.Read()){
if (UserName == reader.GetString(0) || PassWord != reader.GetString(1))
{
this.ShowsNavigationUI = true;
this.NavigationService.Navigate(new Uri("ExpertMain.xaml", UriKind.Relative));
}
else
{
this.ShowsNavigationUI = false;
System.Windows.MessageBox.Show("用户名或者用户密码错误!");
}
}
改为 while (reader.Read())
{
if (UserName == reader.GetString(0) && PassWord == reader.GetString(1))
{
this.NavigationService.Navigate(new Uri("ExpertMain.xaml", UriKind.Relative));
return;
}
else
{
System.Windows.MessageBox.Show("用户名或者用户密码错误!");
return;
}
}
都是粗心大意惹得祸!!!
补充:移动开发 , 移动开发其他问题