标签:参数 9.1 family value rgs create char void sql
private void btn_Login_Click(object sender, EventArgs e)
{
SqlConnection sqlConnection = new SqlConnection();
sqlConnection.ConnectionString =
"Server=(local);Database=EduBaseDemo;Integrated Security=sspi";
SqlCommand sqlCommand = sqlConnection.CreateCommand();
sqlCommand.CommandText =
"SELECT COUNT(1) FROM tb_User WHERE No=@No AND Password=HASHBYTES(‘MD5‘,@Password);")
SqlParameter sqlParameter = new SqlParameter();
sqlParameter.ParameterName = "@No";
sqlParameter.Value = this.UserNo.Text.Trim();
sqlParameter.SqlDbType = SqlDbType.Char;
sqlParameter.Size = 10;
sqlCommand.Parameters.Add(sqlParameter);
sqlConnection.Open();
int rowCount = (int)sqlCommand.ExecuteScalar();
sqlConnection.Close();
if (rowCount == 1)
{
MessageBox.Show("登录成功。");
}
else
{
MessageBox.Show("用户号/密码有误,请重新输入!");
this.Password.Focus();
this.Password.SelectAll();
}
}
标签:参数 9.1 family value rgs create char void sql
原文地址:https://www.cnblogs.com/Holiday-L/p/9658011.html