Recent

Author Topic: Zeos, DBgrid, oracle  (Read 3888 times)

Esskay1

  • Newbie
  • Posts: 2
Zeos, DBgrid, oracle
« on: February 19, 2014, 09:58:59 pm »
I am beginer... I know it is simple question for you..but not for me. so need help wiht this simple program.

 I am trying to connect to oracle database with ZeOS table component and  DBgrid compoent

When i make Ztable.active := true, the records are  displayed in DBgrid.  But problem is some columns  displayed in exponential format

for example

In oracle table, field  AddressID  has value 23489     , on grid it is displayed as  = 2.3E4 ...etc. Is it a bug in Zeos componet?.


Some update: When I use TODBC connection or TOracleConnection componets, AddressID is displayed properly ans integer.
« Last Edit: February 20, 2014, 04:53:43 am by Esskay1 »

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Zeos, DBgrid, oracle
« Reply #1 on: February 20, 2014, 05:36:40 am »
1) this is a zeos specific problem so you might want to post your question on the zeos forums if they exists.
2) As you have found out the different connection objects might return different data types for the same fields use the one that is closer to the server you are using eg TOracleConnection in the case should be better.
3) If the returned data type is a floating point data type then use the displayformat property of the field to show a more human friendly format.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Esskay1

  • Newbie
  • Posts: 2
Re: Zeos, DBgrid, oracle
« Reply #2 on: February 20, 2014, 11:09:13 pm »
I used following statement, after setting active := true.

TFloatField(ZTable1.FieldByName('ADDRESSID')).DisplayFormat := '##########';

and it worked.




Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1269
Re: Zeos, DBgrid, oracle
« Reply #3 on: February 22, 2014, 04:19:59 am »
You will also find that the TField.AsString returns correctly formatted text.  I deal with the issue generically in my app by setting OnGetText for all numeric types (well, the ones I care about anyway):

Code: [Select]
...
  For i := 0 To FDataset.FieldCount - 1 Do
  Begin
    oField := FDataset.Fields[i];

    If oField.DataType In [ftSmallint, ftInteger, ftWord, ftFloat, ftCurrency] Then
      oField.OnGetText := @DatasetOnGetText;
  End;
...

And then...

Code: [Select]
Procedure TFrameGrid.DatasetOnGetText(Sender: TField; Var aText: Ansistring;
  DisplayText: Boolean);
Begin
  aText := Sender.AsString;
End;
Lazarus Trunk/FPC latest fixes on Windows 11
  I'm getting old and stale.  Slowly getting used to git, I'll get there...

 

TinyPortal © 2005-2018