Multiple logins

FadetoBlack

Member
Joined
Mar 11, 2006
Messages
7
Programming Experience
Beginner
I have a table in sql server with some member id and passwords ,I need to verify the validity.I wrote the cose for a single user /password the code im pasting below.Im just stuck when there are multiple users .Just need a lil bit of help in this .Thx

VB.NET:
str = "select  uid ,pass from members where UID='" & TextBox1.Text & "' AND PASS='" & TextBox2.Text & "'"

        comm = New SqlCommand(str, conn)
        Dim dr As SqlDataReader = comm.ExecuteReader



        Try
            If dr.Read = False Then
                MessageBox.Show("Wrong Username/Password")
            Else
                MessageBox.Show("Login successfull")
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
 
VB.NET:
str = "select  uid ,pass from members where UID='" & TextBox1.Text & "'

...
if dr.hasrows=true then
'USER EXISTS
while dr.Read
if dr("pass")=TextBox2.Text then
'USER OK
else
'USER BAD PASS
end if
end while
else
'USER DOES NOT EXIST
end if
 
Personaly I don't see anything wrong with the original code. The user name & passwrod combinations should be unique, so selecting by those should result in 1 (if they are in the table) or 0 (if they are not) results.

-tg
 
Back
Top