Solved

Refreshing ClientDataset

Posted on 2002-07-14
11
1,404 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:János Szabó
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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

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…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

773 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