Solved

DataSet Before Post event

Posted on 2000-02-28
7
412 Views
Last Modified: 2010-04-04
Is it possible to access the existing value of a field(ie the value before this pending post)within this event handler WITHOUT enabling cached updates?

If so, how?

Many thanks
0
Comment
Question by:dasmi
7 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 2564753
what about the BeforePost event?

Zif.
0
 
LVL 9

Expert Comment

by:ITugay
ID: 2564991
If you directly modifying field, for example by TDBEdit, last field value became unavalable. You cannot access last field value by simply way. You can try extract it from database by another Query only :(
0
 
LVL 9

Expert Comment

by:ITugay
ID: 2565004
Hmmm... I forget about.....
.... if you use IBX components, it possible.
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!

 
LVL 27

Expert Comment

by:kretzschmar
ID: 2565011
listening . . .
0
 
LVL 2

Accepted Solution

by:
kubeerja earned 50 total points
ID: 2566330
a simple way is to save it in a variable before Edit and check that value before post.

other wise you need to extract the value from the Active buffer of the DataSet then you can try this function

function TForm1.fDbiGetField(hTmpCur: hDBICur; FieldNo: Word): Variant;

var
  Props: CURProps;
  pFlds, pOldFlds: pFLDDesc;
  pRecBuf: pBYTE;
  FieldString: string;
  FieldINT16: Smallint;
  FieldINT32: Longint;
  FieldUINT16: Word;
  FieldFLOAT: Double;
  Blank: LongBool;
begin
  if (FieldNo < 1) then
    raise EDatabaseError.Create('Field number index is 1 based');

  Check(DbiGetCursorProps(hTmpCur, Props));
  pFlds := AllocMem(Props.iFields * sizeof(FLDDesc));
  pOldFlds := pFlds;

  pRecBuf := AllocMem(Props.iRecBufSize * sizeof(BYTE));
  try
    Check(DbiGetFieldDescs(hTmpCur, pFlds));
    Inc(pFlds, FieldNo - 1);
    Check(DbiGetRecord(hTmpCur, dbiNOLOCK, pRecBuf, nil));
    case pFlds.iFldType of
      fldDATE, fldTIME, fldTIMESTAMP, fldUNKNOWN, fldBLOB, fldBOOL, fldBCD:
        raise EDBEngineError.Create(DBIERR_NOTSUPPORTED);
      fldZSTRING:
      begin
        SetLength(FieldString, pFlds.iUnits1 + 1);

        Check(DbiGetField(hTmpCur, FieldNo, pRecBuf,
          pBYTE(PChar(FieldString)), Blank));
        SetLength(FieldString, StrLen(PChar(FieldString)));
        Result := FieldString;
      end;
      fldINT16:
      begin
        Check(DbiGetField(hTmpCur, FieldNo, pRecBuf, pBYTE(@FieldINT16),
          Blank));
        Result := FieldINT16;
      end;
      fldUINT16:
      begin
        Check(DbiGetField(hTmpCur, FieldNo, pRecBuf, pBYTE(@FieldUINT16),

          Blank));
        Result := FieldUINT16;
      end;
      fldFLOAT:
      begin
        Check(DbiGetField(hTmpCur, FieldNo, pRecBuf, pBYTE(@FieldFLOAT),
          Blank));
        Result := FieldFLOAT;
      end;
      fldINT32, fldUINT32:
      begin
        Check(DbiGetField(hTmpCur, FieldNo, pRecBuf, pBYTE(@FieldINT32),
          Blank));
        Result := FieldINT32;
      end;
    end;
  finally
    FreeMem(pOldFlds, Props.iFields * sizeof(FLDDesc));
    FreeMem(pRecBuf, Props.iRecBufSize * sizeof(BYTE));
  end;
end;

you can call it like this

Label4.Caption:=VarToStr(fDbiGetField(Table1.Handle,Table1.FieldByName('tname').Index + 1)) ;
0
 

Author Comment

by:dasmi
ID: 2566674
It works.

It is a solution which demonstrates a good knowledge of the underlying DB engine. What a great pity it is necessary to go to these lengths to simply get the existing field value(s).

Thank you very much for your prompt response with a fully working solution. I am impressed with the experts exchange service in general, and with kubeerja in particular.

0
 
LVL 2

Expert Comment

by:kubeerja
ID: 2566892
Thank you, :-)
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi TcxGrid group footer summary 3 354
drawing animated level bar based on numbers 3 111
creating threads in delphi 1 157
Tvertscrollbox like a whatsapp layout 5 50
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

740 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