用户处于非活动状态的C#Windows应用程序时未登录 [英] user is not login when he is inactive c# windows application
本文介绍了用户处于非活动状态的C#Windows应用程序时未登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我通过以下方式创建登录表单:我有一个活动/非活动组合框,管理员可以从中选择活动和非活动值以及活动和非活动用户.
我如何在登录时进行检查.我用用户名和密码进行检查.我如何使用用户名和密码进行检查.如何使用用户名和密码进行检查.
i am create login form in that i have active/inactive combobox from where admin select active and inactive value and active and inactive user.
how can i check this at the time of login.i check with username and password how i check with if user is active or not.how can i check with username and password.
const string query1 = ("Select * from emp_tracker_username where username=@username and password=@password");
//cn.Open();
OleDbCommand cmd1 = new OleDbCommand(query1, cn1);
cmd1.Parameters.AddWithValue("@username", txtusername.Text);
cmd1.Parameters.AddWithValue("@password", txtpassword.Text);
OleDbDataAdapter ad1 = new OleDbDataAdapter(cmd1);
DataSet dt1 = new DataSet();
ad1.Fill(dt1);
if (dt1.Tables[0].Rows.Count > 0)
{
Form f4 = new frmCorporateNewid();
f4.Show();
// hiding the first form.
this.Hide();
}
else
{
MessageBox.Show("Login Unsucessful...!");
}
推荐答案
您需要修改命令.试试这个:
You need to modify your command. Try this:
const string query1 = ("Select * from emp_tracker_username where username=@username and password=@password");
//cn.Open();
OleDbCommand cmd1 = new OleDbCommand(query1, cn1);
cmd1.Parameters.AddWithValue("@username", txtusername.Text);
cmd1.Parameters.AddWithValue("@password", txtpassword.Text);
OleDbDataAdapter ad1 = new OleDbDataAdapter(cmd1);
DataSet dt1 = new DataSet();
ad1.Fill(dt1);
if (dt1.Tables[0].Rows.Count > 0)
{
//Active is the table column which is there in datatable of type BIT/Boolean fetched from database
if(Convert.ToBoolean(dt1.Tables[0].Rows[0]["Active"])){
//If use is active
Form f4 = new frmCorporateNewid();
f4.Show();
// hiding the first form.
this.Hide();
}
else{
//Show the message if user is inactive.
MessageBox.Show("User is inactive. Contact your admin");
}
}
else
{
MessageBox.Show("Login Unsucessful...!");
}
--Amit
--Amit
这篇关于用户处于非活动状态的C#Windows应用程序时未登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文