Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

DataSet Before Post event

Posted on 2000-02-28
7
Medium Priority
?
419 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 27

Expert Comment

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

Accepted Solution

by:
kubeerja earned 200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

704 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