Solved

Unable to edit dbgrid

Posted on 2004-08-06
8
345 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 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

Technology Partners: 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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

734 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