Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Database

Posted on 1998-09-08
2
Medium Priority
?
148 Views
Last Modified: 2010-04-06
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.
0
Comment
Question by:lifeson
2 Comments
 
LVL 3

Expert Comment

by:vladika
ID: 1339093
Edit.Text := MyField.AsString
or
Edit.Text := MyTable.FieldByName('MyField').AsString
or
use DBEdit


0
 
LVL 1

Accepted Solution

by:
Marcius earned 100 total points
ID: 1339094
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

783 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