string constr = "Data Source=LBJ\\LBJ1;Initial Catalog=LBJDatebase;integrated Security=true";
using (SqlConnection con = new SqlConnection(constr))
{
string account = textBox1.Text.Trim();
string password = textBox2.Text;
string sql1 = "select count(*) from AcountNum where Account=@acc and Password=@pas";
using (SqlCommand cmd = new SqlCommand(sql1,con))
{
SqlParameter [] pmdata = new SqlParameter[] { new SqlParameter("acc", SqlDbType.NChar, 50) { Value= account },new SqlParameter("pas", SqlDbType.NChar, 50) { Value = password } };
cmd.Parameters.AddRange(pmdata);
con.Open();
int r = (int)cmd.ExecuteScalar();
if (r != 0)
{
MessageBox.Show("登陆成功");
this.Close();
}
else
{
MessageBox.Show("登陆失败");
}
}
}
using (SqlConnection con = new SqlConnection(constr))
{
string account = textBox1.Text.Trim();
string password = textBox2.Text;
string sql1 = "select count(*) from AcountNum where Account=@acc and Password=@pas";
using (SqlCommand cmd = new SqlCommand(sql1,con))
{
SqlParameter [] pmdata = new SqlParameter[] { new SqlParameter("acc", SqlDbType.NChar, 50) { Value= account },new SqlParameter("pas", SqlDbType.NChar, 50) { Value = password } };
cmd.Parameters.AddRange(pmdata);
con.Open();
int r = (int)cmd.ExecuteScalar();
if (r != 0)
{
MessageBox.Show("登陆成功");
this.Close();
}
else
{
MessageBox.Show("登陆失败");
}
}
}