Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

show blob data form into Memo

Status
Not open for further replies.

cheikh1

Programmer
Feb 19, 2003
75
MR
hello to all,
i use delphi5 prof Edition and Interbase6
i have DBGrid component wich display a result of
query, on of the fields is of type blob(contains a text data) i want to display this blob data into a memo when
i click Enter for example.
help me plz(any code will be helpfull).
thank you.
 
cheikh1,

Um, why not simply attach a tDBMemo to the underlying tBlobField created from your query?

Assuming that you really need to use a tMemo, use something like this to populate the memo after running your query:

Code:
   memo1.Lines.Text := FieldByName( 'BLOBFIELD' ).AsString;

You'll note that this properly handles any line breaks stored in the underlying field.

To see this in context, here's an example based on the following conditions:

1. It uses the PROJECT table from the employee.gdb sample database provided with InterBase. (The PROJ_DESC field is a blob.)

2. ComboBox1 is populated in the form's OnCreate event; it's filled with the results of this query:

Code:
select distinct
   PROJ_NAME, PROJ_ID 
from PROJECT

So it contains the list of projects in the table.

3. SqlQuery1's SQL property is defined as follows:

Code:
select distinct *
from PROJECT
where PROJ_NAME = :PROJ_NAME

With all this in mind, here's ComboBox1's OnChange event, which demonstrates the earlier line of code in practice:

Code:
procedure TForm1.ComboBox1Change(Sender: TObject);
begin

   with SQLQuery1 do
   begin
      if active then close;
      Params[ 0 ].AsString := ComboBox1.Text;
      open;

      edit1.Text := FieldByName( 'PROJ_ID' ).AsString;
      edit2.Text := FieldByName( 'TEAM_LEADER' ).AsString;
      edit3.Text := FieldByName( 'PRODUCT' ).AsString;
      memo1.Lines.Text := FieldByName( 'PROJ_DESC' ).AsString;
   end;

end;

Hope this helps...

-- Lance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top