Tchala B

Tchala B

  • NA
  • 52
  • 15.2k

C# code failing to pick user and password from access data

May 16 2017 10:13 AM
I have a windows forms application using ms access database but am having some issue with my login form. When i try to login the code can`t log me in after i input the right password and user name and am wondering what the problem might be
Here is my code
 
  1. DataSet ds = GetData.getInfo("select * from Users where UserName='" + txt1 + "' and Pswd1='" + txt2 + "'""Users");  
  2.                 if (info.Tables[0].Rows.Count > 0)  
  3.                 {  
  4.                     if (info.Tables[0].Rows[0][2].ToString() == txt2)  
  5.                     {  
  6.                         getSettings.SessionId = this.cmbSession.SelectedIndex;  
  7.                         getSettings.Session = this.cmbSession.Text;  
  8.                         if (!string.IsNullOrEmpty(info.Tables[0].Rows[0]["Role_Id"].ToString()))  
  9.                         {  
  10.                             getSettings.UserRoleId = Convert.ToInt32(info.Tables[0].Rows[0]["Role_Id"]);  
  11.                             getSettings.UserRole = this.GetData.getInfo("SELECT Role FROM Role_Master WHERE Role_Id=" + (object)getSettings.UserRoleId);  
  12.                         }  
  13.                         this.DialogResult = DialogResult.OK;  
  14.                         this.Close();  
  15.                           
  16.                     } 

Here is the Users Table

 
 

Answers (2)