Solved

DBMemo and SQL server text

Posted on 1998-04-06
1
618 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

919 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

12 Experts available now in Live!

Get 1:1 Help Now