string SqlString = "select * from Userq where UserName='" + textBox1.Text + "'";
using (SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
SqlCommand com = new SqlCommand(SqlString, conn);
SqlDataReader reader = com.ExecuteReader();
if (reader.HasRows==false)
{
MessageBox.Show("用户名不存在");
return;
}
while (reader.Read())
{
string user = reader.GetString(1);
string pass = reader.GetString(2);
if (textBox2.Text.Trim() == pass)
{
this.Hide();
Form2 f = new Form2(user,pass);
f.Show();
}
else
{
MessageBox.Show("密码错误");
}
}
}
using (SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
SqlCommand com = new SqlCommand(SqlString, conn);
SqlDataReader reader = com.ExecuteReader();
if (reader.HasRows==false)
{
MessageBox.Show("用户名不存在");
return;
}
while (reader.Read())
{
string user = reader.GetString(1);
string pass = reader.GetString(2);
if (textBox2.Text.Trim() == pass)
{
this.Hide();
Form2 f = new Form2(user,pass);
f.Show();
}
else
{
MessageBox.Show("密码错误");
}
}
}