Solved

DBMemo and SQL server text

Posted on 1998-04-06
1
624 Views
Last Modified: 2008-02-01
DBMemo and SQL server text
The SQL database contains a table with text.
The text will be dbmemo in VCL.
UpdateSQL insert by "insert xtable('the_text')
values :thetext,the error told us
Field the_text is of an unsupport type.
Do we have any method to solve the problem? How?
Thank you.
0
Comment
Question by:mathematics
1 Comment
 
LVL 5

Accepted Solution

by:
ronit051397 earned 100 total points
ID: 1361308
This is from Borland forum:

Subject:      Re: Blobs via SQL
                  From:         koterski@SPICEDHAM2borland.com (Steve Koterski)
                  Date:         1998/03/20
                  Message-ID:   <3514c411.13371795@forums.borland.com>
                  Newsgroups:   borland.public.delphi.database.sqlservers
                  [More Headers]


                  On Fri, 20 Mar 1998 14:56:51 +1300, Alistair Clethero <tarac@voyager.co.nz>
                  wrote:

                  >I am using a tquery to duplicate a record in a table 'n' times (it
                  >assigns a unique key via a parameter on each insert). The duplication
                  >works ok except when i try to duplicate one of the fields which is a
                  >text blob - the sql just refuses to like it. Can anyone tell me how i
                  >can insert a blob field using a tquery component, or at least point me
                  >to some SQL info on blobs. Most of the books show how you can use Delphi
                  >components with blobs, but not straight sql.

                  To insert BLOB or memo data through SQL, the BLOB or memo data must be
                  passed as a parameter. On the Delphi side, the parameter must be of type
                  ftBlob or ftMemo, whichever is appropriate for the column type. The data to
                  be inserted must be in the form of a PChar buffer (or equivalent). Prior to
                  executing the query with the UPDATE or INSERT statement, fill the parameter
                  by assigning the PChar buffer to the parameter.

                    procedure TForm1.Button1Click(Sender: TObject);
                    var
                      P: PChar;
                      s: Integer;
                    begin
                      with Query1 do begin
                        ParamByName('StrParm').AsString := 'ABC';
                        s := Memo1.GetTextLen + 1;
                        P := AllocMem(s);
                        try
                          FillChar(P^, s, #0);
                          Memo1.GetTextBuf(P, s);
                          ParamByName('MemoParm').AsMemo := P;
                        finally
                          FreeMem(P, s);
                        end;
                        ExecSQL;
                      end;
                    end;

                  **************************************************************************
                  Steve Koterski
                  Borland International, Inc.
                  http://www.borland.com/delphi
                  (Remove the "SPICEDHAM2" from the address. Death to spam-bots!)


This is from me (Ronit):
The SQL statement should look like this:

SQL.Text:='insert into MyTable values("aaa","bbb"',:P)';
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

821 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