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
here's the code:
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()
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
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
[EDIT]Tags added - LOSMAC[/EDIT]