Solved

Unable to edit dbgrid

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now