if (this.txtUserName.Text == "")
{
MessageBox.Show("用户名不能为空!"); }
else
{
if (this.txtUserPwd.Text == "")
{
MessageBox.Show("密码不能为空!");
}
else
{
try
{
string str = "select UserPwd from tb_User where UserName ='" + this.txtUserName.Text.ToString() + "'";
SqlConnection con = DB.createConnection();
SqlDataAdapter thisDataAdapter = new SqlDataAdapter(str, con);
DataSet myDataset = new DataSet();
thisDataAdapter.Fill(myDataset, "userLogin"); string dataString=myDataset.Tables["userLogin"].Rows[0][0].ToString();
string frmString=this.txtUserPwd.Text.Trim(); if (dataString == frmString)
{
frmMain main = new frmMain();
this.Close();
main.Show();
}
else
{
MessageBox.Show("用户名或密码输入不正确!!!");
}
}
catch (Exception eLogin)
{
MessageBox.Show("用户不存在,请重新输入!");
txtUserName.Text = txtUserPwd.Text = "";
txtUserName.Focus();
}
登陆页面不跳转到mainForm,自动停止调试程序,哪里错了???
{
MessageBox.Show("用户名不能为空!"); }
else
{
if (this.txtUserPwd.Text == "")
{
MessageBox.Show("密码不能为空!");
}
else
{
try
{
string str = "select UserPwd from tb_User where UserName ='" + this.txtUserName.Text.ToString() + "'";
SqlConnection con = DB.createConnection();
SqlDataAdapter thisDataAdapter = new SqlDataAdapter(str, con);
DataSet myDataset = new DataSet();
thisDataAdapter.Fill(myDataset, "userLogin"); string dataString=myDataset.Tables["userLogin"].Rows[0][0].ToString();
string frmString=this.txtUserPwd.Text.Trim(); if (dataString == frmString)
{
frmMain main = new frmMain();
this.Close();
main.Show();
}
else
{
MessageBox.Show("用户名或密码输入不正确!!!");
}
}
catch (Exception eLogin)
{
MessageBox.Show("用户不存在,请重新输入!");
txtUserName.Text = txtUserPwd.Text = "";
txtUserName.Focus();
}
登陆页面不跳转到mainForm,自动停止调试程序,哪里错了???
this.Hiden();
main.Show();