c# - 用户通过 SQL 以多个权限级别登录
问题描述
我想要具有多个权限级别的用户登录,当 Perm_type 为 1 显示管理员时,我的 SQL 有 Perm_type 列,Perm_type 为 2 显示员工
我不知道如何添加代码来检查 Perm_type
我的代码是
public Login_form()
{
InitializeComponent();
/*initialize connection*/
con = new MySqlConnection("Server=localhost;Database=demo;user=demouser;Pwd=demopassword;SslMode=none");
}
private void Login_btn_Click(object sender, EventArgs e) //Log In Button
{
string user = id_txt.Text;
string pass = Pwd_txt.Text;
cmd = new MySqlCommand();
con.Open();
cmd.Connection = con;
cmd.CommandText = "SELECT * FROM demo_login where id='" + id_txt.Text + "' AND password='" + Pwd_txt.Text + "'";
dr = cmd.ExecuteReader();
if (dr.Read())
{
Administrator new_Form = new Administrator();
new_Form.Show();
}
else
{
MessageBox.Show("Invalid Login please check username and password");
}
con.Close();
}
解决方案
推荐阅读
- python - Apply logical and/or operations along an axis in numpy python
- firebase - Retrieving, comparing and sending data from realtime database firebase to flutter
- python - Resolving Compile Errors in Custom Tensorflow Loss Function
- r - 如何控制由 mclapply 引起的潜在 fork 炸弹,尝试 ulimit 但没有用
- javascript - 我可以做些什么来整齐地组织来自 MongoDB 的数据?
- javascript - 如何将参数传递给函数然后在函数中使用它?
- java - 如何在回收站视图的线性布局中获取当前不可见的视图
- javascript - 为基本身份验证反应私有路由
- javascript - express.js 中 req.body 的目的是什么?
- symfony4 - 如何在 EasyAdmin3 symfony4 中为 ChoiceField 设置自定义数据提供者?