Solved

Unable to edit dbgrid

Posted on 2004-08-06
8
342 Views
Last Modified: 2010-04-05
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
Comment
Question by:selas
  • 2
  • 2
8 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 250 total points
ID: 11733812
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
 

Author Comment

by:selas
ID: 11733968
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
 
LVL 2

Assisted Solution

by:DarkCore_
DarkCore_ earned 250 total points
ID: 11734193
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
 

Author Comment

by:selas
ID: 11760600
What event should i use?
0
 
LVL 2

Expert Comment

by:DarkCore_
ID: 11760668
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question