Solved

Refreshing ClientDataset

Posted on 2002-07-14
11
1,402 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
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.

 

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

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

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 94
Delphi TcxGrid group footer summary 3 211
When I am typing into a TEdit last word repeats 7 117
Delphi and Access based Enumeration 9 47
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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

895 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

18 Experts available now in Live!

Get 1:1 Help Now