jeudi 23 juin 2016
TSQLQuery and update of data aware components
I have a sqlite database containing 'notes' for customers. The database design is quite simple and involves one table for notes, a "link" table, linking, relating customers and notes named customer_note and a customers table. The notes table have an id field, the customer_note have customer_id and note_id (one to many) and the customers table have a id as well.
The query to obtain the notes for a selected customer is:
SELECT * FROM note n
INNER JOIN customer_note cn
ON (cn.note_id = n.id)
WHERE customer_id = :customerID
ORDER BY created_on ASC
The query is executed in an event where the customers client dataset is scrolled, i.e.
customersCDSAfterScroll()
{
int cID = customerCDS->FieldByName("id")->AsInteger;
customerNotesQ->Params->ParamByName("customerID")->AsInteger = bID;
customerNotesQ->Open();
//Get notes
string note = stdstr(customerNotesQ->FieldByName("note")->AsString);
Log(lInfo) << "Note is: "<<note;
customerNotesQ->Close();
}
The query is referenced by a DataSetProvider, a ClientDataSet and a DataSource component. On the UI a TDBLookupListbox is receiving the data.
Problem is, the TDBLookpListbox shows ALL notes for all customers.
In the log messages, from the code above, I can see that the query seem to do its job correctly however.
Any idea on what is going wrong?
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire