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."

            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
        End Try
6 Years
Discussion Span
Last Post by JorgeM

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 ------

Edited by JorgeM: incorrect code


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...

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.