Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reference to a field after record search

Status
Not open for further replies.

jpinto

Technical User
Dec 12, 2003
75
PT
Hello,

I've the following code to search a record in the database:
Code:
Public Class LoginForm1

Dim da As OleDb.OleDbDataAdapter

Dim ds As New DataSet

Dim con As New OleDb.OleDbConnection

Dim sSQL As String

Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click

con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=""C:\Programaçao\Visual Basic\Inapal\ReportIt\ReportIt.mdb"";"

con.Open()

sSQL = "SELECT * FROM [Utilizadores] WHERE (User= '" & ComboBox1.Text & "')"

da = New OleDb.OleDbDataAdapter(sSQL, con)

ds.Clear()

da.Fill(ds, "Utilizadores")

Now I want to compare the field "Password" from the Table "Utilizadores" with the value of the "PasswordTextBox" field of a form.

How can I refer to the field?

Thanks,

João Pinto
 
'First, find out if a record was actually found
If ds.Tables(0).Rows.Count > 0 Then

'Next, make sure that only one record was found
If ds.Tables.Rows.Count = 1 Then
'Only one record found, so check password
If ds.Tables(0).Rows(0).Item("Password") = PasswordTextBox.Text.Trim Then
'Password matches, so let them in
Else
'Password does not match, so do what is appropriate in this situation
End If
Else
'more than one record found
'display a message or something
End If
End If

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day! Ye has a choice: talk like a pira
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top