?
Solved

Unable to edit dbgrid

Posted on 2004-08-06
8
Medium Priority
?
348 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
8 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 1000 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 1000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

770 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