Database

How to access the records of a Table manually? For example, i want to put a string recorded in a field called 'Desc', in a Edit.
lifesonAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
MarciusConnect With a Mentor Commented:
Lifeson,

Vladika has really answered this question, but I will provide some more information.

You need to select the correct record in your database table first. To do this, you can use TDataset.Locate or TTable.FindKey. Assuming a table with an integer MyKey as primary key, the syntax would be:

procedure TForm1.SelectMyRecord(MyKey: Integer);
begin
  if MyTable.FindKey([MyKey]) then
     MyEdit.Text := MyTable.FieldByName('MyField').AsString;
end;

The locate is more complicated, but can be used to find a record without using key values.

procedure TForm1.SelectMyRecord(FirstVal, SecondVal: Integer);
begin
  if MyTable.Locate('FirstSearchField;SecondSearchField',
                    VarArrayOf([FirstVal,SecondVal]),[]) then
     MyEdit.Text := MyTable.FieldByName('MyField').AsString;
end;

I hope this helps,

Marcius.
0
 
vladikaCommented:
Edit.Text := MyField.AsString
or
Edit.Text := MyTable.FieldByName('MyField').AsString
or
use DBEdit


0
All Courses

From novice to tech pro — start learning today.