我是Delphi的初學者,我需要以下問題的幫助。我必須在窗體上實現一個可編輯的DBGrid。 DBGrid顯示連接3個表的查詢的結果。我設法使DBGrid可編輯,但編輯對數據庫沒有影響。我可以在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
我可能錯過了一些東西,但我不知道是什麼。任何幫助,將不勝感激!
五月值得一讀:http://stackoverflow.com/questions/12366772 –