Solved

TUpdateSQL question

Posted on 2002-07-18
8
201 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
 

Author Comment

by:roosiedb
ID: 7164250
OK, this make sense.......
I will try this tonight, when I'm back in the "private office" :-)
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

13 Experts available now in Live!

Get 1:1 Help Now