C#: How to check if label value is inside an Access file table?

  • Thread starter Thread starter VA_er
  • Start date Start date
V

VA_er

Guest
For example, I have a label: lblUser.Text = Environment.UserName; (workplace computer, employees have their own unique username)

I also have an Access file: P:\Shared\TestProject\SampleFile.accdb (Workplace shared drive, every group employee can access the drive) One unrelated question to the subject line: If I encrypt this access file by using a password, can the program works fine when checking label value against Access table?

And there is a table inside the Access file: User_access I will add each group member's username in the table (field name: Username ).

I have a button, and how to write the code for comment portion?

Thanks.


private void btnLogin_Click(object sender, EventArgs e)
{
bool AuthorizedUser = false;

//Check if lblUser.Text is in the access table User_access field Username. If it is True, then set AuthorizedUser = true;

if (AuthorizedUser == false)
{
MessageBox.Show("You do not have the permission to access.", "Error Message");
return;
}

if (AuthorizedUser == true)
{
FormInterface fInterface = new FormInterface();
fInterface.Show();
this.Close();
}




}

Continue reading...
 
Back
Top