I'm trying to compare a user name entered into a textbox and searching to see if it is entered into the database, can anyone tell me if i'm heading in the right direction or completely wrong. At the min its not working, so any help would be much appreciated.
Function Search()
Dim cmd As New OleDb.OleDbCommand
Try
Me.OleDbConnection1.Open()
cmd.Connection = OleDbConnection1
cmd.Parameters.Add("@Membership No", Me.txtUser.text)
cmd.CommandType = CommandType.Text
cmd.CommandText = "Select * from Members Where (Membership No = @Membership No)"
reader = cmd.ExecuteReader
reader.Read()
reader.Read.CompareTo(txtUser)
Return True
Catch ex As Exception
Response.Redirect("IncorrectUser.aspx")
End Try
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
If Search(True) Then
Response.Redirect("MembersPage.aspx")
End If
End Sub
Function Search()
Dim cmd As New OleDb.OleDbCommand
Try
Me.OleDbConnection1.Open()
cmd.Connection = OleDbConnection1
cmd.Parameters.Add("@Membership No", Me.txtUser.text)
cmd.CommandType = CommandType.Text
cmd.CommandText = "Select * from Members Where (Membership No = @Membership No)"
reader = cmd.ExecuteReader
reader.Read()
reader.Read.CompareTo(txtUser)
Return True
Catch ex As Exception
Response.Redirect("IncorrectUser.aspx")
End Try
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
If Search(True) Then
Response.Redirect("MembersPage.aspx")
End If
End Sub