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.

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.