我有一個sqlite數據庫包含「筆記」的客戶。數據庫設計非常簡單,包含一張表格用於記錄,一個「鏈接」表格,將客戶和名爲customer_note的筆記與客戶表相關聯。 notes表有一個id字段,customer_note有customer_id和note_id(一對多),而customers表也有一個id。TSQLQuery和數據感知組件的更新
的查詢,以獲取筆記選定的客戶是:
SELECT * FROM note n
INNER JOIN customer_note cn
ON (cn.note_id = n.id)
WHERE customer_id = :customerID
ORDER BY created_on ASC
查詢是在客戶端數據集被滾動的情況下執行,即
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();
}
該查詢由DataSetProvider,ClientDataSet和DataSource組件引用。在UI上,TDBLookupListbox正在接收數據。
問題是,TDBLookpListbox顯示所有客戶的所有筆記。 在日誌消息中,從上面的代碼中,我可以看到查詢似乎正確地完成了它的工作。
有什麼想法出錯了?