Solved

Database

Posted on 1998-09-08
2
140 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 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 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