Solved

Refreshing ClientDataset

Posted on 2002-07-14
11
1,399 Views
Last Modified: 2012-05-04
Hi,

How can I refresh a single record of a ClientDataset when its providerdataset has lookupfields. I have found that RefreshRecord refreshes only the basefields.

Regards, GD.
0
Comment
Question by:goodday
  • 6
  • 4
11 Comments
 
LVL 10

Expert Comment

by:kacor
ID: 7156104
Hi GD,

before refreshing the provider dataset try to refresh the dataset supplying the list elements too. If you use DBNavgator this can be connected to the OnClick event. (see Help: TDBNavigator.OnClick)

wbr

Janos
0
 

Author Comment

by:goodday
ID: 7156518
Hi Janos,

I've tried refreshing the providerdataset before refreshing the Clients record, but there was no change. If I understand the help well, RefreshRecord is not supposed to refresh the lookupfields. I have found it strange ... it must have some practical reason... yet I badly need the value of those lookupfields too...

Regards, GD.
0
 

Author Comment

by:goodday
ID: 7156693
Hi Janos,

I've tried refreshing the providerdataset before refreshing the Clients record, but there was no change. If I understand the help well, RefreshRecord is not supposed to refresh the lookupfields. I have found it strange ... it must have some practical reason... yet I badly need the value of those lookupfields too...

Regards, GD.
0
 

Author Comment

by:goodday
ID: 7156695
Hi Janos,

I've tried refreshing the providerdataset before refreshing the Clients record, but there was no change. If I understand the help well, RefreshRecord is not supposed to refresh the lookupfields. I have found it strange ... it must have some practical reason... yet I badly need the value of those lookupfields too...

Regards, GD.
0
 
LVL 7

Expert Comment

by:Cynna
ID: 7156753
goodday,

I'm afraid you'll have to do some VCL patching...this seems to be the bug in DBCLIENT.PAS.
There is a bug fix and description here:
 http://distribucon.com/midasbug/
Choose your delphi version and click 'Submit',
or go directly to:
http://distribucon.com/servlets/QueryBugsServlet?DelphiVersion=8

Look at the bottom at the page - fix for TCustomClientDataSet.InternalFetch procedure.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:goodday
ID: 7156814
Hi Cynna ,

It sounds very promising. :)))

Is the bug in the TCustomClientDataSet.InternalFetch procedure? How can I Do VCL Patching?

0
 
LVL 7

Expert Comment

by:Cynna
ID: 7156894
> Is the bug in the TCustomClientDataSet.InternalFetch procedure?
It seems so - RefreshRecords directly calls it.

> How can I Do VCL Patching?
Well, the procedure is explained quite well in http://distribucon.com/midasbug/
But let me repeat it:

0. Make a backup of $(DELPHI)\SOURCE\VCL\DBCLIENT.PAS  and $(DELPHI)\LIB\DBCLIENT.DCU files. If anything goes wrong, you can now always fall back to the original...

1. Start a new app
2. Add $(DELPHI)\SOURCE\VCL\DBCLIENT.PAS to your units list
3. Find the TCustomClientDataSet.InternalFetch procedure in DBCLIENT.PAS
4. Delete complete procedure
5. Copy complete TCustomClientDataSet.InternalFetch from http://distribucon.com/servlets/QueryBugsServlet?DelphiVersion=8
6. Paste it in DBCLIENT.PAS, thus replacing the original one with this patched version.
7. Add $(DELPHI)\SOURCE\VCL to your projects search path (Project -> Options -> Directories/Conditionals -> Search Path:)
8. Build All
9. This generates the new DBCLIENT.DCU - copy it to $(DELPHI)\LIB, rewriting the old one. From now on, all your app will use this new, patched DBCLIENT.

10. That's it, close your test app. Now make sure you rebuild your app that uses DBCLIENT to see if patched version does any better...
0
 

Author Comment

by:goodday
ID: 7157934
Cynna,

I did everything the way you suggested, but the ResultValues of LookUpField remained unchanged after refreshing the record. To make sure that the new InterNalFetch was running, I even traced the new DBClient. It seemed so promising ... ;)

Best Regards, GD.
0
 
LVL 7

Accepted Solution

by:
Cynna earned 499 total points
ID: 7158870
:(
Sorry, I didn't test it, but it seemed to tackle your problem...

Ok, let's try patch #2.
All the steps for patching are the same, except you'll be changing PROVIDER.PAS, instead  of DBCLIENT.PAS.
Please remember to make a backup copy!


1. Open PROVIDER.PAS (in VCL)
2. Find procedure TDataSetProvider.UpdateRecord
3. In it, change the line:

 if (Field <> nil) and (not BlobsOnly or (Field.IsBlob and VarIsNull(Fields[i].NewValue))) then
          Fields[i].Assign(Field);

to:

 if (Field <> nil) and  (not (Field.Lookup or Field.Calculated)) and (not BlobsOnly or (Field.IsBlob and VarIsNull(Fields[i].NewValue))) then
          Fields[i].Assign(Field);

4. Repeat all the steps I described in previous post to generate new PROVIDER.DCU
0
 

Author Comment

by:goodday
ID: 7159440
Cynna,

IT'S WORKING!!!!!!!!!!!!!!!!!!!!!

I can't tell you how thankful I am. It took me some time till I was able to stop jumping and laughing so that I could seat back to my PC to tell you about the result. When I read your last comment I was just about to rewrite my whole applicaton ...

Many THANX !!! :))))

GD
 
PS.: The original code was your second code and the corrected replacement the fist one. :))
0
 
LVL 7

Expert Comment

by:Cynna
ID: 7161439
:)
You're very welcome.
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

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

759 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

21 Experts available now in Live!

Get 1:1 Help Now