日期:2014-05-17 浏览次数:20831 次
private void button1_Click(object sender, EventArgs e)
{
SqlCommand s;
s = new SqlCommand();
s.Connection = p;
string str = string.Format("select * from 用户表 where 用户ID={0} and 用户密码={1}",this.textBox1.Text,this.textBox2.Text);
s.CommandText = str;
s.CommandType = CommandType.Text;
SqlDataReader sdr = s.ExecuteReader();
// sdr.Read();
if(sdr.Read())
{
MessageBox.Show("登录成功!");
主窗体 p1 = new 主窗体();
p1.Show();
}
else
{
MessageBox.Show("用户名与密码不匹配!");
}
}