looking for a spesifik row in a tabel by checking for a word in a column

I'm making an application were i've made a tabel called users. When a user tryes to login i need to refeer to that tabel. I need the program first to check wether or not the username exists in the tabel, than i need to sheck what the password to this username is and wheathe or not its the same pasword the user wrote in the pasword textbox. How can i make that?
[364 byte] By [alxandr] at [2007-12-22]
# 1

All you have to do is go through the list of usernames until you find a match, then check the password. The code would be something like:

Public Function VerifyNamePassword(ByVal name As String, ByVal password As String) As Boolean

Dim userNameCol = 0 'column containing username

Dim passwordCol = 1 'column containing password

For i = 0 To (Me.CustomersDataGridView.RowCount - 2)

If Me.CustomersDataGridView.Item(userNameCol, i).Value.ToString.Equals(name) Then

If Me.CustomersDataGridView.Item(passwordCol, i).Value.ToString.Equals(password) Then

Return True 'if match is found

End If

End If

Next

Return False 'gone through entire table and no match is found

End Function


Hope that helps,
Yun

YunZhou_MS at 2007-8-30 > top of Msdn Tech,Visual Basic,Visual Basic General...