Hi All,
I am working on a project using a disconnected data model. My MS Access database has 2 tables: Owner_Table and Pet_Table
When the owner logs in they are navigated to a form where they can view their details on file.
The owner ID is a field in both tables of the database. When the owner logs in I want their details from the Owner_Table to be displayed as well as the Pet Name from the Pet_Table.
This is the code which I have been working on to no avail!
I know the approach I am using might not be the correct one. I would appreciate any help at all.Code:Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click Dim user As String = txtUsername.Text Dim pass As String = txtPassword.Text Dim result As Boolean = False For i As Integer = 0 To objDataSet.Tables("Owner_Table").Rows.Count - 1 If tel = CStr(objDataSet.Tables("Owner_Table").Rows(i).Item("Username")) And pass = CStr(objDataSet.Tables("Owner_Table").Rows(i).Item("Password")) Then result = True MessageBox.Show("Welcome " & objDataSet.Tables("Owner_Table").Rows(i).Item("Name")) frmOwner.lblOwnerID2.Text = CStr(objDataSet.Tables("Owner_Table").Rows(i).Item("Owner_ID")) frmOwner.lblName2.Text = CStr(objDataSet.Tables("Owner_Table").Rows(i).Item("Name")) frmOwner.lblAddress2.Text = CStr(objDataSet.Tables("Owner_Table").Rows(i).Item("Address")) frmOwner.lblTelephone2.Text = CStr(objDataSet.Tables("Owner_Table").Rows(i).Item("Telephone")) Dim objOwner As DataRow Dim objPet As DataRow Dim strPetName As String 'Find the current owner record objCustomer = objDataSet.Tables("Owner_Table").Rows.Find(frmOwner.lblOwnerID2.Text.ToString) 'Loop through each record for this row, as per the relationship 'Then add the pet name to the label For Each objPet In objOwner.GetChildRows("Owner_Table2Pet_Table") strPetName = objPet.Item("Pet_Name") frmOwner.lblPetName2.Text = strPetName Next frmOwner.Show() Me.Hide() End If Next If result = False Then MessageBox.Show("The username/password combination you have entered is incorrect", "Error") txtUsername.Clear() txtPassword.Clear() End If End Sub
Thanks in advance.
Dave




Reply With Quote
