what sql command i must use. this is my current command but it give me an error saying "The specified filed 'ClientNo' could refer to more than one table listed in the FROM clause of your sql statemate."

Try
            dc.Connection = conn
            dc.CommandText = "SELECT * FROM tblClient, tblClientInfo WHERE ClientNo =  '" & ClientNo & "'"
            dr = dc.ExecuteReader

            If dr.HasRows Then
                While dr.Read
                    frmClientsProfile.lblClientNo.Text = dr.Item(0)
                    frmClientsProfile.lblFirstName.Text = dr.Item(1)
                    frmClientsProfile.lblLastName.Text = dr.Item(2)
                    frmClientsProfile.lblAge.Text = dr.Item(3)
                    frmClientsProfile.lblAddress.Text = dr.Item(4)
                    frmClientsProfile.lblBirthday.Text = dr.Item(5)
                    frmClientsProfile.lblGender.Text = dr.Item(6)
                    frmClientsProfile.lblContactNo.Text = dr.Item(7)

                    frmClientsProfile.lblGFirstName.Text = dr.Item(8)
                    frmClientsProfile.lblGLastName.Text = dr.Item(9)
                    frmClientsProfile.lblGAge.Text = dr.Item(10)
                    frmClientsProfile.lblGAddress.Text = dr.Item(11)
                    frmClientsProfile.lblGBirthday.Text = dr.Item(12)
                    frmClientsProfile.lblGGender.Text = dr.Item(13)
                    frmClientsProfile.lblGContactNo.Text = dr.Item(14)

                    frmClientsProfile.lblLoan.Text = dr.Item(16)
                    frmClientsProfile.lblPaid.Text = dr.Item(17)
                    frmClientsProfile.lblBalance.Text = dr.Item(16) - dr.Item(17)
                    frmClientsProfile.lblSavings.Text = dr.Item(18) - dr.Item(19)
                    'frmClientsProfile.lblTermStart.Text = dr.Item(19)
                    'frmClientsProfile.lblTermEnd.Text = dr.Item(20)
                End While

            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

Recommended Answers

All 3 Replies

If you fields are coming from multiple tables, and the same field name exist in more than one table, you need to be more specific about the field name in the query string.

for example,

[EDIT] ----Incorrect code ------

what field name should i put?

My mistake, disregard what I had posted.

Just specifiy the tableName in the where clause.... for example,

SELECT * FROM tblClient,tblClientInfo WHERE tableNAME.ClientNo =

Sorry about that...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.