• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1228
  • Last Modified:

MEmo field with sql server and delphi 5

i wana create a database in sql server and  use it from an application with delphi 5 program
a have some memo fields in my table
1-witch data type in my table i should use
2- how can i use these fields in quickreport in my program
in qreport tab in delphi i cant find a qrdbmemo in it
1 Solution
Daniel WilsonCommented:
On SQL 2000:
If you really NEED a field longer than 8000 characters use Text or NText if you need Unicode.  Otherwise, use varchar(8000) or nvarchar(4000) if you need Unicode.

On SQL 2005:
You have the option of using varchar(MAX) or nvarchar(MAX) for Unicode.  That will give you a field of up to 2^31 -1 bytes.

Hope that gets part 1 for you.
 QuickReports will use whatever field type you decide to use.  The problem with the memo style fields is that, with a program like QuickReports, you set a size it can display in on your report.  Anything outside this size will not be printed.  I believe you can set the field to auto size.  The problem with autosizing is that you could easily have your text spread across hundreds of pages... defeating the idea of having it on a report (the format would be shot).  If you need to use a non-memo field on your report (I think the regular field should work) then you can use SQL to return it as a text field of the size you want to print on your report.

Convert(varchar(200), MyMemoField) MyMemoField

Let me know if this helps.

I am printing memo fields from SQL table with TQRMemo(in example QMemo) this way:

  redit : TRichedit;

form create event:
   redit := TRichEdit.Create(form1);
   redit.MaxLength := $7FFFFFF0;
   redit.Parent := form1;
   redit.Visible := False;
procedure TForm1.DetailBeforePrint(Sender: TQRCustomBand; var PrintBand: Boolean);
  x : integer;
  mst : TMemoryStream;
  mst := TMemoryStream.Create;
  mst.LoadFromStream(CreateBlobStream(Query.FieldByName('my_memo_field'), bmRead));
  mst.position := 0;
  if length(trim(StrPas(PCHAR(redit.lines.text)))) > 0 then
      if redit.lines.Count > 10 then
           x := 0;
                x := x + 1;
           until x = redit.lines.Count;
           QMemo.Height := QMemo.lines.Count * 15;
           Detail.Height := QMemo.Height + 12;
      else QMemo.lines.Text := redit.lines.Text;


Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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