[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 143
  • Last Modified:

Basic Database Manipulation

Hello Experts!

I am new to Delphi.  I want to get a data from a certain table of my database without using TDBEdit.  I will have to use TEdit.  I want to set the initial value of TEdit to the first row from my table and once NEXT button is click, it will point to the next row.

Could anybody give me an idea on how to do this ?

Regards!
Entrance2002 :-)
0
Renante Entera
Asked:
Renante Entera
  • 3
3 Solutions
 
mokuleCommented:
You should use TTable or TQuery or TADOTable or TADOQuery or similar

Then

Table1.First goes to first row

Table1.Next goes to next row

Table1.FieldByName('fieldname').AsString gives You the desired field value.
0
 
esoftbgCommented:
it is important to use the event AfterScroll of the DataSet:

procedure TForm1.Query1AfterScroll(DataSet: TDataSet);
begin
  Edit1.Text := Query1.FieldByName('........').AsString;
end;
0
 
geobulCommented:
Alternatively you may use Form1.OnCreate event to set the initial state and Button1.Click (NEXT button) for reading next values:

procedure TForm1.FormCreate(Sender: TObject);
begin
  Table1.Open;
  Edit1.Text := Table1.FieldByName('Field1').AsString;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Table1.Next;
  if not Table1.eof then Edit1.Text := Table1.FieldByName('Field1').AsString;
end;

Regards, Geo
0
 
esoftbgCommented:
download a simple example from         http://www.geocities.com/esoftbg/ee/Q_20958765.zip
0
 
esoftbgCommented:
page:        http://www.geocities.com/esoftbg/
link:          Q_20958765.zip
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now