vb.net 2008 login using ms access

5 pts.
Tags:
Microsoft Access
VB.NET 2008
hi guys,ive been working on trying to create a login form. ms Access side: -used a logininfo.mdb database with columns :username,password,job vb 2008 side: -login form with clerk rad button,manager rad button,username text box,password textbox and login button now the challenge im having is that only the "Clerk" can login properly,ive used the same code for "Manager" but just swapped the variables.however "manager" cant login pls pls pls help asap,gotta submit this system soon Imports System.Data.OleDb Public Class database Public Sub login() Dim con As New OleDb.OleDbConnection con.ConnectionString = "PROVIDER=Microsoft.JET.OLEDB.4.0;Data Source = ..logininfo.mdb" Dim cmd As OleDbCommand = New OleDbCommand("SELECT job,username,password FROM login where username=? and password=?", con)   cmd.Parameters.AddWithValue("username", Form1.TextBox1.Text) cmd.Parameters.AddWithValue("password", Form1.TextBox2.Text)   Try con.Open() Dim read As OleDbDataReader = cmd.ExecuteReader()   If read.HasRows Then read.Read()   ''validate clerk If Form1.TextBox1.Text.ToLower() = read.Item("username").ToString And Form1.TextBox2.Text.ToLower = read.Item("password").ToString And Form1.rdbclerk.Checked Then MsgBox("Login successful") frmclk.ShowDialog() Form1.Hide()   Else If String.IsNullOrEmpty(Form1.TextBox1.Text) Xor String.IsNullOrEmpty(Form1.TextBox2.Text) Xor Form1.rdbclerk.Checked = False _ Xor Form1.rdbmgr.Checked Then MsgBox("emp Login unsuccessful,pls type the correct details and select the correct usertype") End If End If   'validate manager If Form1.TextBox1.Text.ToLower() = read.Item("username").ToString And Form1.TextBox2.Text.ToLower = read.Item("password").ToString And Form1.rdbmgr.Checked Then MsgBox("Login successful") frmclk.ShowDialog() Form1.Hide()   Else If String.IsNullOrEmpty(Form1.TextBox1.Text) Xor String.IsNullOrEmpty(Form1.TextBox2.Text) Xor Form1.rdbclerk.Checked = False _ Xor Form1.rdbclerk.Checked Then MsgBox("emp Login unsuccessful,pls type the correct details and select the correct usertype") End If End If   Else MsgBox("Login unsuccessful,no connection") End If   read.Close() Catch ex As Exception MessageBox.Show(ex.Message) Finally con.Close() End Try   End Sub End Class[/pre]

Software/Hardware used:
vb.net 2008

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • tlsanders1
    Looks to me like your READ is only reading the first record. When you compare the clerk's login info against it, it is OK, but when you compare the manager's login info against the first record from the database, it fails. I think you need a way to loop through the records of the password database.
    1,340 pointsBadges:
    report
  • carlosdl
    "Looks to me like your READ is only reading the first record." I don't think it needs to read more than 1 record, since only one user will be being validated on each try. I think part of the problem is here: Else If String.IsNullOrEmpty(Form1.TextBox1.Text) Xor String.IsNullOrEmpty(Form1.TextBox2.Text) Xor Form1.rdbclerk.Checked = False _ Xor Form1.rdbmgr.Checked Then MsgBox("emp Login unsuccessful,pls type the correct details and select the correct usertype") End If End If Because of this code, if rdbmgr is checked, an unsuccessful login message will be displayed, no matter what the user entered as username and password. But, it seems that it should then continue to validate using the manager validation code, and display a login successful message if the provided credentials were correct. Dissector, can you tell us what happens when you try to login as a manager ?
    69,990 pointsBadges:
    report
  • tlsanders1
    Oops, Carlosdl is correct. I didn't follow the logic. The way the IFs are set up the program flow doesn't have a chance to get to the manager vaildation.
    1,340 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following