I need help. Need to do password validation and have no idea why it doesn't work. Could someone tell me what my code is missing or what is actually wrong with my way of thinking? I am connecting it to dataset2 where is the table called Users2. Table consists of two columns: 'Username' and 'Password'. Users2BiningSou rce.Find should be returning value of an index where a current query is. The returned value is always -1, what I guess means that is not found (false). I am using Microsoft Visual Studio 2012 along with SQL server 2008 SP3, all on windows 7. Thank you for your time and help!
Code:
Imports Hotel_Booking_System.DataSet2TableAdapters
Public Class Logging
Public Sub check_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.Check_Details()
End Sub
Private Sub Quit_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Close()
End Sub
Public Sub Logging_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Users2TableAdapter.Fill(Me.DataSet2.Users2)
'TODO: This line of code loads data into the 'DataSet2.Users2' table. You can move, or remove it, as needed.
End Sub
Public Sub Check_Details()
Me.Users2BindingSource.AddNew()
Dim Usrnm As String = ""
Usrnm = txtUsername.Text
Dim Pswrd As String = ""
Pswrd = txtPassword.Text
Dim Found As Integer
Found = Users2BindingSource.Find("Username", Usrnm)
Dim Found2 As Integer
Found2 = Users2BindingSource.Find("Password", Pswrd)
If Found >= 0 And Found2 >= 0 And Usrnm = "Admin" Then
Me.Hide()
Booking.Show()
ElseIf Found >= 0 And Found2 >= 0 Then
Me.Hide()
Rooms.Show()
Else
MsgBox("Wrong username or password. Please try again", MsgBoxStyle.DefaultButton1, "SOMETHING WENT WRONG")
End If
Label1.Text = Found 'checking the value of found
Label2.Text = Found2 ' checking the value of found2
End Sub
End Class
Comment