0

Hi All,

I have cut this down to a simple example.
The access file has a table called rooms which contains a description field of type memo

I want to load this into a dbmemo (delphi 7) I run this by a button onclick event

procedure TForm1.Button1Click(Sender: TObject);
begin
adoquery1.close;
adoquery1.SQL.Clear;
ADOQuery1.SQL.Add('Select description from Rooms');
adoquery1.Active := true;
adoquery1.Open;
end;

problem is that it puts nothing in the dbmemo.
I can get it to work with a dbgrid, but I guess thats not the point.

Further, I am not sure how to debug this kind of code to see what is happening, hints to that effect would be appreciated also.

Thanks.

Edited by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by glubbish
0
procedure TForm1.Button1Click(Sender: TObject);
begin

DataSource1.DataSet := adoquery1;
DbMemo1.DataSource := DataSource1;
DbMemo1.DataField := 'description';
with adoquery1 do 
   begin
      if Active then Close;
      SQL.Clear;
      SQL.Add('Select description from Rooms');
      //adoquery1.Active := true; you don't have to make the query active as you open it in the next line.
      Open;
   end;
end;

Now, your dbMemo should be filled with the text from the first record in the dataset. So, you have to loop through dataset to get what do you need.

For debugging, I put watches and use DataSet.FieldByNAme('column_name').asString to see the value in the current record.

Cheers,
Ionut

0

Thanks Ionut.

The problem was (as you suggested)
DbMemo1.DataField := 'description';

I am still trying to get my head around the relationship between the different ado objects
but appreciate your answer to this. I can now move forward on my project.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.