【发布时间】:2016-06-16 16:24:41
【问题描述】:
我有一个包含客户“笔记”的 sqlite 数据库。数据库设计非常简单,包括一张便笺表、一个“链接”表、链接、关联客户和名为 customer_note 的便笺以及一个客户表。 notes 表有一个 id 字段,customer_note 有 customer_id 和 note_id(一对多),customers 表也有一个 id。
获取所选客户备注的查询是:
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 显示所有客户的所有注释。 在日志消息中,从上面的代码中,我可以看到查询似乎正确地完成了它的工作。
知道出了什么问题吗?
【问题讨论】: