Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i want to login form in vb.net using ms access for Admin and staff.If admin login the form , it show the main form . if staff login the  form,it show the main2 form. pls help my project...pls give me the coding


What I have tried:

login the form for admin and staff
Posted
Updated 9-Apr-18 23:53pm
Comments
Sunasara Imdadhusen 10-Apr-18 5:45am    
Have you started writing code?
Member 13738315 10-Apr-18 7:18am    
s bro
Member 13738315 10-Apr-18 7:21am    
If Len(Trim(ComboBox1.Text)) = 0 Then
MessageBox.Show("Please select user type", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
ComboBox1.Focus()
Exit Sub
End If
If Len(Trim(TextBox1.Text)) = 0 Then
MessageBox.Show("Please enter user name", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
TextBox1.Focus()
Exit Sub
End If
If Len(Trim(TextBox2.Text)) = 0 Then
MessageBox.Show("Please enter password", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
TextBox2.Focus()
Exit Sub
End If
Try
Dim myConnection As OleDbConnection
myConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\Attendance.mdb.accdb;Persist Security Info=False;")
Dim myCommand As OleDbCommand
myCommand = New OleDbCommand("SELECT users.username,User_password FROM Users,Registration where Registration.Username=users.username and Users.Username = @Username and user_password = @UserPassword", myConnection)

Dim uName As New OleDbParameter("@Username", SqlDbType.VarChar)
Dim uPassword As New OleDbParameter("@UserPassword", SqlDbType.VarChar)
uName.Value = TextBox1.Text
uPassword.Value = TextBox2.Text
myCommand.Parameters.Add(uName)

myCommand.Parameters.Add(uPassword)

myCommand.Connection.Open()

Dim myReader As OleDbDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)

Dim Login As Object = 0

If myReader.HasRows Then

myReader.Read()

Login = myReader(Login)



End If

If Login = Nothing Then

MsgBox("Login is Failed...Try again !", MsgBoxStyle.Critical, "Login Denied")
TextBox1.Clear()
TextBox2.Clear()
TextBox1.Focus()

Else
ProgressBar1.Visible = True
ProgressBar1.Maximum = 5000
ProgressBar1.Minimum = 0
ProgressBar1.Value = 4
ProgressBar1.Step = 1

For i = 0 To 5000
ProgressBar1.PerformStep()

Next
Me.Hide()
Me.Label1.Hide()
Me.TextBox1.Hide()
Me.Label2.Hide()
Me.TextBox2.Hide()
Me.Button1.Hide()
Me.Button2.Hide()
Me.LinkLabel1.Hide()
Me.Label3.Hide()
Me.Label6.Hide()
Me.ComboBox1.Hide()



Main.Show()

End If
myCommand.Dispose()
myConnection.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub

This is my coding bro...but i dont know how to mentiooned condition to two types of usertype login opened two different forms.
Richard MacCutchan 10-Apr-18 6:09am    
This site does not exist to do your work for you.
Member 13738315 14-Apr-18 5:47am    
thanks bro...can tell me the same code in sql server 2008 and vb.net....pls bro

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900