Article View: borland.public.cppbuilder.database.ado
Article #1388Re: Storing Unicode text to ntext field of MS SQL 2000 Server
From: Viatcheslav V. Vassiliev
Date: Thu, 01 Jul 2004 16:33
Date: Thu, 01 Jul 2004 16:33
76 lines
3229 bytes
3229 bytes
ADO Express converts Memo field into ASCII. Try use recordset itself:
ADOQuery1.Recordset.Fields['xml'].Value := TntMemo2.Lines.Text;
Get value back the same way.
//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"Michael Kuhl" <no_emails@gmx.de> �������/�������� � �������� ���������:
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 ;
> //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
> //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;
> //TWideStringField(ADOQuery1.FieldByName('xml')).AsString :=
> TntMemo2.Lines.Text;
>
> // bstream :=
> TADOBlobStream(ADOQuery1.CreateBlobStream(ADOQuery1.FieldByName('xml'),
> bmReadWrite));
> //bstream.CopyFrom(stream, 0);
>
> ADOQuery1.Post;
>
> // ADOQuery1.Edit;
> // ADOQuery1.Recordset.Fields['xml'].Value := TntMemo2.Lines.Text;
> // ADOQuery1.Post;
>
> ADOConnection1.CommitTrans;
> //bstream.Destroy;
> except
> ADOConnection1.RollbackTrans;
> end;
> stream.free;
> end;
>
> Any suggestions?
>
> Best regards
>
> Michael
>
>
Technical Details
Message-ID:
<40e43cbf$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<40e427af$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: "Viatcheslav V. Vassiliev" <support@oledbdirect.com> Newsgroups: borland.public.cppbuilder.database.ado References: <40e427af$1@newsgroups.borland.com> Subject: Re: Storing Unicode text to ntext field of MS SQL 2000 Server Date: Thu, 1 Jul 2004 20:33:03 +0400 Lines: 78 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: 213.234.218.42 Message-ID: <40e43cbf$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1088699583 213.234.218.42 (1 Jul 2004 09:33:03 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!news.compaq.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail