• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 352
  • Last Modified:

Unable to edit dbgrid

I'm using sql query:

Select id, slapyvardis, lankomumas, zaidzia, sum(inesta), sum(atiduota), laikas, ivede, bonusai, (sum(inesta)* 0.02 + sum(atiduota)*0.01) as siulomi from esantys
where laikas > '2004.08.05' AND laikas < '2004.08.06' AND inesta >= 100 AND atiduota >= 0 group by id order by siulomi desc

and i can't edit any row in dbgrid...
0
selas
Asked:
selas
  • 2
  • 2
2 Solutions
 
kretzschmarCommented:
because by this select the dataset is readonly

the readonyl is caused by
- aggregate functions
- order by clause (only bde relevant)

just tell me why you want to get it editable,
a workaround wold be to use a tstringgrid and fill there the dataset-content
or
to use cachedupdates with an updatesql-component as updateobject of your query
or
to use a memorydataset

meikl ;-)
0
 
selasAuthor Commented:
i want to be able to edit only bonusai field
siulomi - this is sugested bonuses by program
and bonusai - this is real bonuses that i will give
0
 
DarkCore_Commented:
siulomi is an aggregated field, so you can't edit it in any way.

Another alternative is show another modal dialog ( when double click or "modify" is pressed ) where to put the values ( without DBControls ) and modify them with a SQL Statment, and then refresh the dataset.

Edu
0
 
selasAuthor Commented:
What event should i use?
0
 
DarkCore_Commented:
you can try to use, in the DBGrid, the Option "dgRowSelect" to select the entire row and, on the OnDblClick Event, show your edit form ( as modal ). If ModalResult is set to True ( you added/changed the record ), then try to refresh the dataset

curr_id := Dataset.FieldByName('id').value;
Dataset.DisableControls;
Dataset.close;
Dataset.Open;
Dataset.Locate('id', curr_id, [locaseinsensitive] );
Dataset.EnableControls;
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now