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
Solved

TUpdateSQL question

Posted on 2002-07-18
8
205 Views
Last Modified: 2010-07-27
I'm developing a multi-user application with Paradox database tables. All systems do have their setting LocalShare = true (BDE).

In the window "customer maintenance" I am using a TQuery to display all records in a TDBGrid component. Furthermore, I am trying to use a TSQLUpdate component to maintain the data. At the moment that I click on Post (of the TDBNavigator) the following procedure will be executed:

TFormCustMaint.Query1AfterPost(DataSet: TDataSet);
begin
  Query1.ApplyUpdates;
  Query1.Active := false;
  Query1.Active := true;
end;

The new record will be inserted but the focus (within the TDBGrid component) will change to the first record of the table. I have tried to use TBookmark but this will not work (I think because of some AutoInc fields within the table?).

Question: how can I make sure that the focus will stay on the same record after the Query1AfterPost event has been launched?
Note: maybe I am "mis-using" the TSQLUpdate component? Sorry for that... I am still that beginner... :-)

Thank you in advance.
RoosieDB
0
Comment
Question by:roosiedb
8 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7163251
hi,

Store/remember your keyfields
(fields which can identify the record unique),
which are not autoinc-values
and then do a locate after open

if you don't have such other keyfields,
then i guess you have to redesign
by avoiding autoinc-values

(maybe a method to supply this fields
with a number before posting)

meikl ;-)
0
 

Author Comment

by:roosiedb
ID: 7164160
How can I store/remember the keyfields?
I have tried to use TBookmark but this won't work (I think because the AutoInc-field doesn't have a value at that moment yet?)...

And my only goal is to have a screen in which I can maintain a list of articles, by using a TSQLUpdate component. As soon as a new record has been inserted, I want to apply these changes and see my DBGrid displaying the records in the right order again (with the cursor on the record which just has been inserted).

thx.
RoosieDB
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7164175
>How can I store/remember the keyfields?

TFormCustMaint.Query1AfterPost(DataSet: TDataSet);
var
  f1,f2,f3 : String; //by other types, other vars
begin
 f1 := Query1.FieldByName('Field1').AsString; //by other types, other conversion
 f2 := Query1.FieldByName('Field2').AsString;
 f3 := Query1.FieldByName('Field3').AsString;
 Query1.ApplyUpdates;
 Query1.Active := false;
 Query1.Active := true;
 Query1.Locate('Field1;Field2;Field3',VarArrayOf([f1,f2,f3]),[]);
end;

just from head

meikl ;-)


0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:roosiedb
ID: 7164250
OK, this make sense.......
I will try this tonight, when I'm back in the "private office" :-)
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 50 total points
ID: 7168949
any results?
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7179522
just asking again:
any results?
0
 

Expert Comment

by:CleanupPing
ID: 9343036
roosiedb:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 5

Expert Comment

by:Lukasz Lach
ID: 9461268
roosiedb,
No comment has been added lately (18 days), so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:

RECOMMENDATION: Award points to kretzschmar http:#7163251

Please leave any comments here within 7 days.

-- Please DO NOT accept this comment as an answer ! --

Thanks,

anAKiN
EE Cleanup Volunteer
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

856 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