Solved

Database

Posted on 1998-09-08
2
139 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
Comment Utility
Edit.Text := MyField.AsString
or
Edit.Text := MyTable.FieldByName('MyField').AsString
or
use DBEdit


0
 
LVL 1

Accepted Solution

by:
Marcius earned 50 total points
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now