dctechuser
Technical User
I'm in a learning phase of Vb, and I am trying to develop a Login form that will look in the sequel server database and pull the UserName and Password along with role.
I have setup a User table in the Sequel Server 2005 database. The fields are: Username, Password, and Admin.
I have created the windows form with a UserNameTextBox and PasswordTextBox. I have loaded a UserTableAdapter and created a Query called Login:
The Select Statement is setup as:
SELECT COUNT(*) AS Expr1, Admin
FROM Users
WHERE (UserName = @Username) AND (Password = @Password)
GROUP BY Admin
This query runs and gives me the correct record when the UserName and Password parameters are passed.
My Visual Basic coding for the Login button event when clicked:
Try
If CType(Me.UsersTableAdapter.Login(Me.UserNameTextBox.Text, _
Me.PasswordTextBox.Text), Integer) > 0 Then
MessageBox.Show("Welcome")
Else
MsgBox("Invalid UserName and Password.")
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
I need to capture what is in the Admin field. If the Admin field contains a "1", I want an Admin Menu to load. If Admin field contains a "0", I want a tech form to load after the the OK button is clicked on the Welcome message box. If I can capture what is in the Admin Field, I can write an If statement to do what I want if the AdmintextBox.text = "1" or "0". I just need to be able to reference the field somehow.
Any help getting me in the right direction is appreciated.
dctechuser
I have setup a User table in the Sequel Server 2005 database. The fields are: Username, Password, and Admin.
I have created the windows form with a UserNameTextBox and PasswordTextBox. I have loaded a UserTableAdapter and created a Query called Login:
The Select Statement is setup as:
SELECT COUNT(*) AS Expr1, Admin
FROM Users
WHERE (UserName = @Username) AND (Password = @Password)
GROUP BY Admin
This query runs and gives me the correct record when the UserName and Password parameters are passed.
My Visual Basic coding for the Login button event when clicked:
Try
If CType(Me.UsersTableAdapter.Login(Me.UserNameTextBox.Text, _
Me.PasswordTextBox.Text), Integer) > 0 Then
MessageBox.Show("Welcome")
Else
MsgBox("Invalid UserName and Password.")
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
I need to capture what is in the Admin field. If the Admin field contains a "1", I want an Admin Menu to load. If Admin field contains a "0", I want a tech form to load after the the OK button is clicked on the Welcome message box. If I can capture what is in the Admin Field, I can write an If statement to do what I want if the AdmintextBox.text = "1" or "0". I just need to be able to reference the field somehow.
Any help getting me in the right direction is appreciated.
dctechuser