Solved

Refreshing ClientDataset

Posted on 2002-07-14
11
1,409 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
[X]
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
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

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 I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

724 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