Jump to content
Sign in to follow this  
Celso Henrique

Edit dataset results

Recommended Posts

Hi people,

 

I need a help to do something that in my mind is very easy: edit a dataset results.

 

I work with a layers pattern where I have in my form just a ClientDataSet. I have a class function that return a OleVariant object. And I have a FDQuery in a DataModule with my SQL Query.

 

To make my work easy, I have a fuction that creates a DataSetProvider just to take de resultset from FDQuery.

 

Example:

 

In Form:

cdsList.Close;
cdsList.Data := TMyClass.getList;

 

In Class:

dmMyDM.qryGetList.Close;
dmMyDM.qryGetList.Open;

Result := getData(dmMyDM.qryGetList); 

 

In getData method:

LDataSetProvider         := TDataSetProvider.Create(nil);
LDataSetProvider.DataSet := AQuery;

Result := LDataSetProvider.Data;

FreeAndNil(LDataSetProvider);

 

Problem:

Manytimes I can't change the data on ClientDataSet because the field come from FDQuery with property ReadOnly set. I tried a lot of settings to change this and nothing worked.

 

I don't want to send back this data to use update, insert or delete database rules. I just want to edit the data and send it forward.

 

Is there a way to disable all this feature and keep the resultset completely editable?

 

Thanks in advance! 

Share this post


Link to post

Huh, I was struggling the same task these days. In general (IDK about ClientDS particularity) the scheme for datasets is:

- Copy FieldDefs from source dataset (or get them from DB if connected directly) - here ReadOnly appears

- Create Fields based on Defs - here the field gets ReadOnly flag

- Copy data values

 

In theory, you can plug between #1 and #2 to modify Defs. In practice, it depends on how the component is written. It could skip buffer allocation for modified values so the changes won't be saved.

In my case I tried many things to add modifiable custom field to ADO query but was fed up and used memory dataset (which I also had to update for things to work)

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×