Question

In my form I have TADOQuery,TDataSetProvider,TClientDataSet,TDataSource,TDBGrid linked.

AdoQuery use SQL Server view to query data

AdoQuery.SQL:

Select * from vu_Name where fld=:fldval

Vu_Name:

SELECT * FROM  t1 INNER JOIN t2 ON t2.fld1 = t2.fld1

in my dbgrid, only columns in table t1 are editable.(only t1 need to update )

What are the possible (fastest) ways to apply updates back to the server? ClientDataSet.ApplyUpdates(0); // not working

Thank you.

Was it helpful?

Solution

TDataSetProvider has an event OnGetTableName where you should set the TableName parameter to t1. Thus the provider knows where to store the changed values.

You have to make sure that only fields of t1 are changed as TDataSetProvider will only update one table. Of course you can have different table names for different calls to ApplyUpdates. You can find out about changed fields in the DataSet parameter.

If you want to update more than one table you have to implement OnUpdateData, which gives you all of the freedom with all of the responsibility.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top