Hi all
I have 2 DataGridView that are populated with the following SQL query:
and related with the following code:
In the master grid are listed all records from the DocuMaster Table and, when I click on one line of the grid I find the details listed on the details grid.
All works as I expected. All work fine until i must select a record on the master grid.
At this point the 2 grid are empty and the query fails but I don't find a mistake.
If I delete the WHERE clause all return to work.
Thanks you in advance for any help
Robert.
I have 2 DataGridView that are populated with the following SQL query:
Code:
masterSQL = "SELECT BM.Code, BM.NumOrder, CL.Name, AG.Name, TX.Description, CM.Description " & _
" FROM ((((DocuMaster BM) " & _
" LEFT JOIN Clients CL ON BM.CodClient = CL.Code) " & _
" LEFT JOIN Agents AG ON BM.CodAgent = AG.Code) " & _
" LEFT JOIN TabeStore CM ON BM.CauStore = CM.Code) " & _
" LEFT JOIN OrderType TX ON BM.CodOrder = TX.Code "
detailSQL = "SELECT BD.DocuMaster, AM.Description " & _
"FROM DocuDetail BD, Articles AM " & _
" WHERE BD.Article = AM.Code"
Code:
Dim datA As New DataSet
datA.Locale = System.Globalization.CultureInfo.InvariantCulture
Dim masterDataAdapter As New OleDbDataAdapter(masterSQL, Con)
masterDataAdapter.Fill(datA, "DocuMaster")
Dim detailsDataAdapter As New OleDbDataAdapter(detailSQL, Con)
detailsDataAdapter.Fill(datA, "DocuDetail")
Dim Relation As New DataRelation("MovBol", datA.Tables("DocuMaster").Columns("Code"), _
datA.Tables("DocuDetail").Columns("DocuMaster"))
datA.Relations.Add(Relation)
masterBindingSource.DataSource = datA
masterBindingSource.DataMember = "DocuMaster"
detailsBindingSource.DataSource = masterBindingSource
detailsBindingSource.DataMember = "MovBol"
In the master grid are listed all records from the DocuMaster Table and, when I click on one line of the grid I find the details listed on the details grid.
All works as I expected. All work fine until i must select a record on the master grid.
Code:
masterSQL = masterSQL & " WHERE BM.NumOrder = '000001'"
If I delete the WHERE clause all return to work.
Thanks you in advance for any help
Robert.