๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #1484

Re: Storing Unicode text to ntext field of MS SQL 2000 Server

#1484
From: Michael Kuhl
Date: Thu, 01 Jul 2004 15:37
91 lines
3454 bytes
Hello James,

I tried this but it didn't work. I just get rubbish when I try to store e.g.
japanese text.

Best regards

"James Peterson" <jpeterson@romanmealmilling.com> schrieb im Newsbeitrag
news:40e4291a$1@newsgroups.borland.com...
> try something like this
>
>  TStream *Blob
> =ADOQuery1->CreateBlobStream(ADOQuery1->FieldByName("nTextField"),
bmWrite);
>     try {
>         RichEdit7->Lines->SaveToStream(Blob);
>     }
>     __finally {
>         delete Blob;
>     }
>
>   This works for me reading from a RichEdit. Saves all formating of
> charactors and everything.
>
>
>
> "Michael Kuhl" <no_emails@gmx.de> wrote in message
> news:40e427af$1@newsgroups.borland.com...
> > Hello,
> >
> > I'm trying to save an unicode text (memo) to a ntext field. I tried
> several
> > ways to store the text (like you see below) but non of them worked (I'm
> only
> > getting questions marks when I read out the data). My nvarchar field is
> > working fine.
> >
> > I'm using Delphi 5 and the Tnt Components.
> >
> > procedure TForm1.Button1Click(Sender: TObject);
> > var  stream: TStringStream ;
> >      file://bstream: TADOBlobStream;
> > begin
> >   stream := TStringStream.Create('');
> >   try
> >     ADOConnection1.BeginTrans;
> >
> >     ADOQuery1.Append;
> >     ADOQuery1.FieldByName('id').AsInteger       := StrToInt(Edit1.Text);
> >     ADOQuery1.FieldByName('Text').AsVariant     := TntEdit1.Text; //
> > nvarchar
> >     file://ADOQuery1.FieldByName('xml').AsVariant := '';  // ntext
> >
> >     stream.size := 0;  // Inhalt l๏ฟฝschen
> >     TntMemo2.Lines.SaveToStream(stream, false);
> >     stream.Position := 0;
> >     // TBlobField(ADOQuery1.FieldByName('xml')).LoadFromStream(stream);
> >
> >     TWideStringField(ADOQuery1.FieldByName('xml')).AsVariant :=
> > TntMemo2.Lines.Text;
> >     file://TWideStringField(ADOQuery1.FieldByName('xml')).AsString :=
> > TntMemo2.Lines.Text;
> >
> >     // bstream :=
> > TADOBlobStream(ADOQuery1.CreateBlobStream(ADOQuery1.FieldByName('xml'),
> > bmReadWrite));
> >     file://bstream.CopyFrom(stream, 0);
> >
> >     ADOQuery1.Post;
> >
> >     // ADOQuery1.Edit;
> >     // ADOQuery1.Recordset.Fields['xml'].Value := TntMemo2.Lines.Text;
> >     // ADOQuery1.Post;
> >
> >     ADOConnection1.CommitTrans;
> >     file://bstream.Destroy;
> >   except
> >     ADOConnection1.RollbackTrans;
> >   end;
> >   stream.free;
> > end;
> >
> > Any suggestions?
> >
> > Best regards
> >
> > Michael
> >
> >
>
>
Technical Details
Message-ID: <40e42fc7@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40e427af$1@newsgroups.borland.com> <40e4291a$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,456515383264a299
X-Google-Attributes: gid10698b,public
X-Google-Language: ENGLISH,ASCII
From: "Michael Kuhl" <no_emails@gmx.de>
Newsgroups: borland.public.cppbuilder.database.ado
References: <40e427af$1@newsgroups.borland.com> <40e4291a$1@newsgroups.borland.com>
Subject: Re: Storing Unicode text to ntext field of MS SQL 2000 Server
Date: Thu, 1 Jul 2004 17:37:38 +0200
Lines: 93
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 217.235.163.8
Message-ID: <40e42fc7@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1088696263 217.235.163.8 (1 Jul 2004 08:37:43 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail