good day. i have a problem with my login from.
i have my table under SQL server 2008. which is
tbl_user,with a field of userid,username,password and category
i created a simple login form but that's fine and working as a simple login..
my problem is that i want to add user level for the program. if the category is user he/she will be restricted for some form, but if the user category admin then he/she will access to all form on the system..
here my code
private sub btnOK_Click ()
Dim con As New SqlClient.SqlConnection("Data Source=BRMS-SERVER;Initial Catalog=CavsuDB;Integrated Security=True")
Dim cmd As New SqlClient.SqlCommand("SELECT username,password,category FROM tbl_user WHERE username = @username AND password = @password", con)
Dim usernameParam As New SqlClient.SqlParameter("@username", Me.txtUser.Text)
Dim passwordParam As New SqlClient.SqlParameter("@password", Me.txtPass.Text)
cmd.Parameters.Add(usernameParam)
cmd.Parameters.Add(passwordParam)
cmd.Connection.Open()
Dim reader As SqlClient.SqlDataReader = cmd.ExecuteReader()
If reader.HasRows Then
Main.Show()
Me.Hide()
If chkAdmin.Checked = True Then
cmd.CommandText = "SELECt username, password FROM tbl_user where category 'Admin' "
Main.AddUserToolStripMenuItem.Enabled = True
Main.DocumentToolStripMenuItem.Enabled = True
Main.SubjectsToolStripMenuItem.Enabled = True
Main.FacultyToolStripMenuItem.Enabled = True
Main.DepartmentToolStripMenuItem.Enabled = True
'
ElseIf chkAdmin.Checked = False Then
cmd.CommandText = "SELECT username,password FROM tbl_user WHERE category = 'user'"
Main.AddUserToolStripMenuItem.Enabled = False
Main.DocumentToolStripMenuItem.Enabled = True
Main.SubjectsToolStripMenuItem.Enabled = False
Main.FacultyToolStripMenuItem.Enabled = False
Main.DepartmentToolStripMenuItem.Enabled = False
End If
Else
MessageBox.Show("username and or password are not found")
txtUser.Clear()
txtPass.Clear()
txtUser.Focus()
End If
con.Close()