MEmo field with sql server and delphi 5

Posted on 2007-07-21
Last Modified: 2013-11-23
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
Question by:mhyassin
    LVL 32

    Expert Comment

    by:Daniel Wilson
    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.
    LVL 21

    Expert Comment

     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.
    LVL 6

    Accepted Solution


    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

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
    Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now