我是 Delphi 的初学者,我需要帮助解决以下问题。我必须在我的表单上实现一个可编辑的 DBGrid。DBGrid 显示连接 3 个表的查询的结果。我设法使 DBGrid 可编辑,但编辑对数据库没有影响。我可以在 DBGrid 中插入、编辑或删除行,但这些更改不会保存到数据库中。我有以下设置:
Query2.DatabaseName=Test
Query2.SQL=SELECT cd.hourstart, cd.hourfinish, o.objname, cd."work", cd.worktime
FROM Card c JOIN CardDetail cd ON c.N=cd.card
JOIN objects o ON cd.project=o.N
WHERE c.worker=5 AND c.data=CONVERT(DATE, GETDATE())
Query2.UpdateObject=UpdateSQL2
Query2.CachedUpdates=True
Query2.RequestLive=True
UpdateSQL2.DeleteSQL=delete from CardDetail
where hourstart = :OLD_houerstart and
hourfinish = :OLD_houerfinish and
work = :OLD_work and
worktime = :OLD_worktime
UpdateSQL2.InsertSQL=...
UpdateSQL2.ModifySQL=...
DataSource2.DataSet=Query2
DBGrid2.DataSource=DataSource2
我可能错过了一些东西,但我不知道是什么。任何帮助,将不胜感激!