So I have a DBGrid filled with an SQL query. I want the query to be read only so the table isn't locked up while the program is running. The problem is when it is set to read only I can't edit the table at all.

What I want to do is be able to edit the fields on the DBGrid while in readonly mode and then update it after all at once so I don't have to leave the connection open.

I'm not really sure how to do this though. DBGrid doesn't have an OnChange event, so I can't just run an update query every time a cell is changed.

Anyone have some ideas?

有帮助吗?

解决方案

This is the exact reason that TClientDataSet was written. It allows you to take a snapshot of data, store it in memory, update it as if it were an actual dataset, and then easily apply those updates back to the original database.

There's a tutorial here that's not too bad. You can find another one at Scalabium, and a series at the Embarcadero site that Cary Jensen later turned into a book (you can find it at Amazon - don't have a link handy).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top