Solved

Database

Posted on 1998-09-08
2
145 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 50 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

729 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