//登录效验
private void button1_Click(object sender, EventArgs e)
{
string str;
int n;
DataSet ds = new DataSet();
OleDbDataAdapter da;
str = "select `user`,`pws`,`role` from `user` where `user`='" + comboBox1.Text + "'";
//MessageBox.Show(str);
try
{
da = new System.Data.OleDb.OleDbDataAdapter(str, oleDbConnection1);
da.Fill(ds);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
//ds.Tables[0].Rows[0][1];
try
{
Form1.info.user = ds.Tables[0].Rows[0][0].ToString();
Form1.info.pws = ds.Tables[0].Rows[0][1].ToString();
Form1.info.role = ds.Tables[0].Rows[0][2].ToString();
//MessageBox.Show(Form1.info.user + Form1.info.pws + Form1.info.role);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
n = 0;
try
{
if ((textBox1.Text.CompareTo(Form1.info.role)) > 0)
{//登录成功
Form1 f1 = new Form1();
this.Hide();
f1.Show(); }
else
{//登录失败三次,退出系统
n++;
if (n >= 3)
{
MessageBox.Show("登录失败超过三次,系统自动退出!", "登录信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
this.Close();
}
else
{
MessageBox.Show("用户不存在或密码错误!", "登录信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
textBox1.Text = "";
textBox1.Focus();
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
错误信息是:问题很严重,程序要关闭
private void button1_Click(object sender, EventArgs e)
{
string str;
int n;
DataSet ds = new DataSet();
OleDbDataAdapter da;
str = "select `user`,`pws`,`role` from `user` where `user`='" + comboBox1.Text + "'";
//MessageBox.Show(str);
try
{
da = new System.Data.OleDb.OleDbDataAdapter(str, oleDbConnection1);
da.Fill(ds);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
//ds.Tables[0].Rows[0][1];
try
{
Form1.info.user = ds.Tables[0].Rows[0][0].ToString();
Form1.info.pws = ds.Tables[0].Rows[0][1].ToString();
Form1.info.role = ds.Tables[0].Rows[0][2].ToString();
//MessageBox.Show(Form1.info.user + Form1.info.pws + Form1.info.role);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
n = 0;
try
{
if ((textBox1.Text.CompareTo(Form1.info.role)) > 0)
{//登录成功
Form1 f1 = new Form1();
this.Hide();
f1.Show(); }
else
{//登录失败三次,退出系统
n++;
if (n >= 3)
{
MessageBox.Show("登录失败超过三次,系统自动退出!", "登录信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
this.Close();
}
else
{
MessageBox.Show("用户不存在或密码错误!", "登录信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
textBox1.Text = "";
textBox1.Focus();
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
错误信息是:问题很严重,程序要关闭
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货