Share via

Error when joining 3 sql tables

Jeff Stiegler 466 Reputation points
2021-08-09T15:40:04.36+00:00

When joining 3 SQL tables using the code below I receive the following error message.

System.Data.SqlClient.SqlException
HResult=0x80131904
Message=The multi-part identifier "fpapdoption.facct" could not be bound.
Source=.Net SqlClient Data Provider

 Dim strSelect1 = "SELECT fosterparent.facct, classify, l_code, sacct, last_name,   first_name, last_o, first_o, " &
                         "county, status, birth_date, birth_da_o, dl_no, dl_no_o, education, educ_s, race, race_o, fa_book, income, ladder, " &
                         "addr_mail, mar_status, l_code, pool_fence, religion, relig_o, ss_no, ss_no_o, sacct, spa_pict, ncer_date, " &
                         "fprecert.first_b, fprecert.first_1, first_2, last_b, last_1, last_2, " &
                         "fpadoption.ml_rec, fpadoption.ml_rec_o, fpadoption.ml_rec_b, fpadoption.ml_rec_1, fpadoption.ml_rec_2 " &
                         "FROM fosterparent " &
                         "JOIN fprecert ON fosterparent.facct = fprecert.facct " &
                         "JOIN fpadoption ON fosterparent.facct = fpapdoption.facct " &
                         "WHERE fosterparent.status2 = 'Approved' and (fosterparent.status = 'Apprvd-Active' or fosterparent.status = 'Cert.-Active')"

        Dim FieldName = String.Empty

        Dim objCommand1 As New SqlCommand(strSelect1, objConnection)

        ' Open connection if closed
        If objConnection.State = ConnectionState.Closed Then objConnection.Open()

        objSQLDataReader1 = objCommand1.ExecuteReader()

Any ideas?

Developer technologies | VB
0 comments No comments

Answer accepted by question author

Viorel 127K Reputation points
2021-08-09T16:09:32.71+00:00

Replace fpapdoption with fpadoption.

Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.