954,529 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Need help loading a dbmemo from an access file

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.

glubbish
Newbie Poster
13 posts since Apr 2009
Reputation Points: 10
Solved Threads: 1
 
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

Ionelul
Junior Poster in Training
94 posts since Dec 2009
Reputation Points: 17
Solved Threads: 27
 

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.

glubbish
Newbie Poster
13 posts since Apr 2009
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You