Board index » delphi » newbee question please help

newbee question please help

Hi folks

i am working on my first delphi project and i have a question about
databases. When i have a database and would like to change a fields content,
what command should i use ?

The field on record 1 now holds a #  (lets say 2) and i want to change that
into 4 ?
I have been looking into the help files but i just can't seem to find the
answer

Thanks in advance

Robert

 

Re:newbee question please help


Ha Koekie,

if not(Table1.State in[dsEdit, dsInsert]) then Table1.Edit;
Table1.FieldByName('ANUMBER').AsInteger:= 4;
Table1.Post;

Groenten,
Ruben

Quote
Cookie wrote:
> Hi folks

> i am working on my first delphi project and i have a question about
> databases. When i have a database and would like to change a fields content,
> what command should i use ?

> The field on record 1 now holds a #  (lets say 2) and i want to change that
> into 4 ?
> I have been looking into the help files but i just can't seem to find the
> answer

> Thanks in advance

> Robert

Re:newbee question please help


werkt perfect

dank je ruben
Ruben van Leeuwen heeft geschreven in bericht
<370292F6.75F5B...@multiweb.nl>...

Quote
>Ha Koekie,

>if not(Table1.State in[dsEdit, dsInsert]) then Table1.Edit;
>Table1.FieldByName('ANUMBER').AsInteger:= 4;
>Table1.Post;

>Groenten,
>Ruben

Re:newbee question please help


First of all (I'm not sure of this) you can access only one record at any
time (this if you are using the TTable component, as I think); make sure
that you are on the record that you want to modify;

Exist INFINITIVE methods, using TTable, to access a particulary record:
    LOCATE
    FINDKEY
    FINDNEAREST
    NEXT
    FIRST...

Once you have selected the record, you need to enter in the edit mode
(Table1.Edit);
Each field in your DB is stored in a TField component(TTable have a list of
TField called TFieldDefs);
you can now use one of this method to change one or more field:
    Table1.FieldByName('fieldname1').AsInteger:=4;
    Table1.FieldByName('fieldname2').AsString:='Ciao';
    Table1.FindField('fieldname3').Value:=VarArrayOf['abc'];
    ...
Note that to modify a field of a record you have to modify one of the TField
components listed in the TTable.TFieldDefs.

Don't forget at the end to post your change by calling Table1.Post (or
Table1.Cancel if you don't want to save changes); Inserting or Appending
records are used in the same way only that a new record is created and the
cursor points on it.
For more information look at the TField and TFieldDefs on Delphi on-line
help.

Cookie ha scritto nel messaggio <7dttv5$krh...@reader3.wxs.nl>...

Quote
>Hi folks
>i am working on my first delphi project and i have a question about
>databases. When i have a database and would like to change a fields
content,
>what command should i use ?
>The field on record 1 now holds a #  (lets say 2) and i want to change that
>into 4 ?
>I have been looking into the help files but i just can't seem to find the
>answer
>Thanks in advance
>Robert

Other Threads