Solved

DataSet Before Post event

Posted on 2000-02-28
7
405 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
Comment Utility
what about the BeforePost event?

Zif.
0
 
LVL 9

Expert Comment

by:ITugay
Comment Utility
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
Comment Utility
Hmmm... I forget about.....
.... if you use IBX components, it possible.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 27

Expert Comment

by:kretzschmar
Comment Utility
listening . . .
0
 
LVL 2

Accepted Solution

by:
kubeerja earned 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you, :-)
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
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, fr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 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

12 Experts available now in Live!

Get 1:1 Help Now