Recent

Author Topic: How to naviguate in a DBF table...  (Read 6433 times)

ecitoyen

  • Jr. Member
  • **
  • Posts: 51
How to naviguate in a DBF table...
« on: July 06, 2010, 02:15:31 am »
 %) %) %)
How to naviguate in a DBF table...

I have a table NAME.DBF with 1000 records...
Record:

First Name Character 20
Name Character 30
Address Character 50

I can open the table in Lazarus...
and i can get the quantity of records.


But now, if i want to get access to each
record(read each record) and put data
in memory variable....

In dB2K i can use
 FOR i=1 to 1000
 goto i      (record i)
 Var1=First Name
 Var2=Name
 Var3=Address
ENDFOR

How i can do something like that
with lazarus...

Thanks A lot
ecitoyen
simon.brouillard1@voila.fr


stonefull

  • Jr. Member
  • **
  • Posts: 54
Re: How to naviguate in a DBF table...
« Reply #1 on: July 06, 2010, 03:33:31 am »
Use TDBF

  dbf1.First;
  while not dbf1.EOF do
  begin
     Var1 := dbf1.FieldByName('FIRST_NAME').AsString;
     Var2 := dbf1.FieldByName('NAME').AsString;
     Var3 := db1.FieldByName('ADDRESS').AsString;
     dbf1.Next;
  end;

ecitoyen

  • Jr. Member
  • **
  • Posts: 51
Re: How to naviguate in a DBF table...
« Reply #2 on: July 06, 2010, 01:40:53 pm »
 :D
I will try it today and i will give you a comment!
Dear teacher!
 O:-)

ecitoyen

  • Jr. Member
  • **
  • Posts: 51
Re: How to naviguate in a DBF table...
« Reply #3 on: July 06, 2010, 03:47:07 pm »
 8)
Dear stonefull,

I will try it... and it's working...

I put my table variable in a one-dimension array Var,
convert it(Var to a TStringlist) and put it in a Combobox.
Thanks a lot...

It's furrny...

erkka

  • New Member
  • *
  • Posts: 37
Re: How to naviguate in a DBF table...
« Reply #4 on: August 08, 2010, 11:50:45 am »
I jump in with my related question  ::)

Now I'm using

  Dbf1 : TDbf;
  CustomersDb : TDbf;

  cn:=Dbf1.FieldByName('customer').AsInteger;
  CustomersDb.First;
  CustomersDb.MoveBy(cn);
  Label3.Caption:=CustomersDb.FieldByName('name').AsString;

to access the name of customer #cn

It works, but is there something like CustomersDb.Goto(cn) ?


 

TinyPortal © 2005-2018