Solved

Refreshing ClientDataset

Posted on 2002-07-14
11
1,405 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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
 

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

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

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…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

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