你在哪家公司工作呀?
完整版的
public static int i=0;
private void button1_Click(object sender, EventArgs e)
{
try
{
if (textBox1.Text.Trim() == "" && textBox2.Text.Trim() == "")
{
MessageBox.Show("请输入完整信息");
}
else
{
string name, pwd;
name = textBox1.Text;
pwd = textBox2.Text;
SqlConnection con = new SqlConnection("server=192.168.1.58;database=goods;uid=sa;pwd=;");
SqlDataAdapter da = new SqlDataAdapter("select name from employee where name='" + name + "'", con);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
SqlDataAdapter da1 = new SqlDataAdapter("select * from employee where name='" + name + "' and pwd='"+pwd+"'", con);
DataSet ds1 = new DataSet();
da1.Fill(ds1);
if (ds1.Tables[0].Rows.Count > 0)
{
MessageBox.Show("登录成功");
}
else
{
MessageBox.Show("密码错误重新输入");
i++;
if (i > 3)
{
this.Close();
}
}
}
else
{
i++;
if (i > 3)
{
this.Close();
}
else
{
MessageBox.Show("该用户名不存在");
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}