1 Replies - 4559 Views - Last Post: 15 April 2012 - 10:30 AM

#1 timosilver  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 115
  • Joined: 20-March 11

sql select statement to verify username and password

Posted 15 April 2012 - 01:45 AM

Hello,

i have below code that verifies my login form.
The problem is that it only authenticates one particular
username and password on the database.

i have other usernames and password in same table as well
but only one get authenticated.

Help..!

Thanks

Dim mypath = Application.StartupPath & "\lsbds.mdb"
            Dim mypassword = "kingss"
            Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mypath & ";Jet OLEDB:Database Password=" & mypassword)
            Dim cmd As OleDbCommand

            Me.Hide()
            Dim sql = "SELECT Username ,Password FROM Logintable WHERE Username='" & TextBox1.Text & "' AND Password='" & TextBox2.Text & "'"

            cmd = New OleDbCommand(sql, conn)
            conn.Open()
            Dim dr As OleDbDataReader = cmd.ExecuteReader

            Try
                If dr.Read = False Then
                    MessageBox.Show("Login failed...")
                    Me.Show()
                Else
                    MessageBox.Show("Login successfully...")

                End If
            Catch ex As Exception
            End Try

            conn.Close()
        End If

    End Sub


Is This A Good Question/Topic? 0
  • +

Replies To: sql select statement to verify username and password

#2 June7  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 104
  • View blog
  • Posts: 904
  • Joined: 09-December 08

Re: sql select statement to verify username and password

Posted 15 April 2012 - 10:30 AM

Is this a VB.net project using Access as a data backend? If so (and the code indicates it is) the question is actually a VB issue, not Access/VBA.

Have you step debugged? Follow the code as it executes, see why it deviates from expected behavior, fix, repeat.

This post has been edited by June7: 15 April 2012 - 10:32 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1