Solved

DataSet Before Post event

Posted on 2000-02-28
7
415 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
[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
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses
Course of the Month6 days, 14 hours left to enroll

623 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