Article View: borland.public.cppbuilder.database.ado
Article #1480Storing Unicode text to ntext field of MS SQL 2000 Server
From: Michael Kuhl
Date: Thu, 01 Jul 2004 15:03
Date: Thu, 01 Jul 2004 15:03
57 lines
2434 bytes
2434 bytes
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:
<40e427af$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!feed.news.schlund.de!schlund.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10698b,456515383264a299,start X-Google-Attributes: gid10698b,public X-Google-Language: ENGLISH,ASCII From: "Michael Kuhl" <no_emails@gmx.de> Newsgroups: borland.public.cppbuilder.database.ado Subject: Storing Unicode text to ntext field of MS SQL 2000 Server Date: Thu, 1 Jul 2004 17:03:03 +0200 Lines: 59 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: <40e427af$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1088694191 217.235.163.8 (1 Jul 2004 08:03:11 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!feed.news.schlund.de!schlund.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail