Solved

TUpdateSQL question

Posted on 2002-07-18
8
203 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 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

19 Experts available now in Live!

Get 1:1 Help Now