線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:2359
推到 Plurk!
推到 Facebook!

UNICODE文字新增到 SQL SERVER 問題

答題得分者是:Stallion
foxelf
初階會員


發表:9
回覆:42
積分:30
註冊:2003-03-05

發送簡訊給我
#1 引用回覆 回覆 發表時間:2009-07-30 11:39:47 IP:220.136.xxx.xxx 訂閱
各位先進
小弟有個欄位是ntext型態的欄位,因為考慮到這個欄位所新增的文字長度會非常長,所以不考慮用組SQL的方式,
我想用ADOQuery.Parameters.ParamByName('XXX').VALUE := TNTMEMO.TEXT ; 的方式,但是SQL要存入UNIOCDE的資料需要在資料前面加N,
才能確保存入的資料是UNICODE的型態,請問還有哪些方式可以利用
Stallion
版主


發表:52
回覆:1600
積分:1995
註冊:2004-09-15

發送簡訊給我
#2 引用回覆 回覆 發表時間:2009-08-01 14:11:39 IP:75.35.xxx.xxx 未訂閱
Field Type = nvarchar
foxelf
初階會員


發表:9
回覆:42
積分:30
註冊:2003-03-05

發送簡訊給我
#3 引用回覆 回覆 發表時間:2009-08-03 11:29:29 IP:118.168.xxx.xxx 訂閱
Stallion大大你好
我的欄位是 nText 型態,欄位要存的資料會很多
我也試過指定 DATATYPE := ftWideString 但是會自動變成 ftFixedChar
所以我只有在用組SQL方式有成功過,用ParamByName('DataMemo').Value := TntMemo1.Text ;存到資料庫UNICODE字元都會變成"?"

===================引 用 Stallion 文 章===================
Field Type = nvarchar
Stallion
版主


發表:52
回覆:1600
積分:1995
註冊:2004-09-15

發送簡訊給我
#4 引用回覆 回覆 發表時間:2009-08-03 13:26:07 IP:75.18.xxx.xxx 未訂閱
As I know TADOQuery doesn't support unicode manipulation, use TNTUnicodecontrol and it's extention TNTEx (there's TTntADOQuery inside).
Please check out below link and then you can find those files, and download TntUnicodeControl 2.1.11 then you will have no problem to comply with TntEX.

http://www.yunqa.de/delphi/doku.php/products/tntunicodecontrols/index ( this link is for TNTUnicodeControl)

http://web.archive.org/web/*sr_11nr_10/http://download.tntware.com/* ( this link is for TNTEx)

By the way, you need to read and write unicode value trough TTntADOQuery as below example .

aQuery.ParamValue['DataMemo'] := TntMemo1.Text;

or

TntMemo1.Text := aQuery.ParamValue['DataMemo'];
編輯記錄
Stallion 重新編輯於 2009-08-03 13:27:21, 註解 無‧
foxelf
初階會員


發表:9
回覆:42
積分:30
註冊:2003-03-05

發送簡訊給我
#5 引用回覆 回覆 發表時間:2009-08-03 13:49:44 IP:118.168.xxx.xxx 訂閱
Stallion你好
TNTADOQuery 我試過也是不行,ParamValue好像沒這個屬性,但我用過aQuery.FieldValues['XXX'] := TntMemo1.Text
結果還是一樣的


===================引 用 Stallion 文 章===================
As I know TADOQuery doesn't support unicode manipulation, use TNTUnicodecontrol and it's extention TNTEx (there's TTntADOQuery inside).
Please check out below link and then you can find those files, and download TntUnicodeControl 2.1.11 then you will have no problem to comply with TntEX.

http://www.yunqa.de/delphi/doku.php/products/tntunicodecontrols/index ( this link is for TNTUnicodeControl)

http://web.archive.org/web/*sr_11nr_10/http://download.tntware.com/* ( this link is for TNTEx)

By the way, you need to read and write unicode value trough TTntADOQuery as below example .

aQuery.ParamValue['DataMemo'] := TntMemo1.Text;

or

TntMemo1.Text := aQuery.ParamValue['DataMemo'];
Stallion
版主


發表:52
回覆:1600
積分:1995
註冊:2004-09-15

發送簡訊給我
#6 引用回覆 回覆 發表時間:2009-08-04 12:34:30 IP:75.35.xxx.xxx 未訂閱
yes, my fault, it should be
aQuery.FieldValue['XXX'] := TntMemo1.Text;

and I also checked MSSQL online book that ntext does support unicode char, and I did successfully access MSSQL Server ntext, nvarchar fields with unicode string before by the method shown above. That's all I can tell you, you need to find where your codes go wrong, or you may post the snippet of codes here, other experts here could find out the problem for you.
===================引 用 foxelf 文 章===================
Stallion你好
TNTADOQuery 我試過也是不行,ParamValue好像沒這個屬性,但我用過aQuery.FieldValues['XXX'] := TntMemo1.Text
結果還是一樣的


===================引 用 Stallion 文 章===================
As I know TADOQuery doesn't support unicode manipulation, use TNTUnicodecontrol and it's extention TNTEx (there's TTntADOQuery inside).
Please check out below link and then you can find those files, and download TntUnicodeControl 2.1.11 then you will have no problem to comply with TntEX.

http://www.yunqa.de/delphi/doku.php/products/tntunicodecontrols/index ( this link is for TNTUnicodeControl)

http://web.archive.org/web/*sr_11nr_10/http://download.tntware.com/* ( this link is for TNTEx)

By the way, you need to read and write unicode value trough TTntADOQuery as below example .

aQuery.ParamValue['DataMemo'] := TntMemo1.Text;

or

TntMemo1.Text := aQuery.ParamValue['DataMemo'];
foxelf
初階會員


發表:9
回覆:42
積分:30
註冊:2003-03-05

發送簡訊給我
#7 引用回覆 回覆 發表時間:2009-08-04 15:31:47 IP:118.168.xxx.xxx 訂閱
Stallion你好
我寫的CODE如下,我 INSERT 的資料UNICODE的部分還是會變成"?"
我有找到其他方法解決,但並不是最好的解決方式

aQuery.Append ;
aQuery.FieldValues['No'] := No ;
aQuery.FieldValues['Court'] := bQuery.FieldByName('Court').AsInteger ;
aQuery.FieldValues['year'] := bQuery.FieldByName('year').AsString ;
aQuery.FieldValues['date'] := bQuery.FieldByName('Jdate').AsString ;
// fullText = nText Type Field
aQuery.FieldValues['fullText'] := bQuery.FieldByName('fullText').AsVariant ;
aQuery.FieldValues['Analysis'] := bQuery.FieldByName('Analysis').AsString ;
aQuery.FieldValues['Debate'] := bQuery.FieldByName('Debate').AsVariant ;
aQuery.FieldValues['FactExc'] := bQuery.FieldByName('FactExc').AsVariant ;
aQuery.FieldValues['key'] := Id ;
aQuery.Post ;

===================引 用 Stallion 文 章===================
yes, my fault, it should be
aQuery.FieldValue['XXX'] := TntMemo1.Text;

and I also checked MSSQL online book that ntext does support unicode char, and I did successfully access MSSQL Server ntext, nvarchar fields with unicode string before by the method shown above. That's all I can tell you, you need to find where your codes go wrong, or you may post the snippet of codes here, other experts here could find out the problem for you.

============================================
以下恕刪
Stallion
版主


發表:52
回覆:1600
積分:1995
註冊:2004-09-15

發送簡訊給我
#8 引用回覆 回覆 發表時間:2009-08-05 11:40:32 IP:75.35.xxx.xxx 未訂閱
please make sure bQuery is also a TTntADOQury class.

aQuery.Append ;
aQuery.FieldValues['No'] := No ;
aQuery.FieldValues['Court'] := bQuery.FieldByName('Court').AsInteger ; // if this field type is digit, then it doesn't have to be revised as below.
aQuery.FieldValues['year'] := bQuery.FieldByName('year').AsString ; // same as above
aQuery.FieldValues['date'] := bQuery.FieldByName('Jdate').AsString ; // same as above
// fullText = nText Type Field
aQuery.FieldValues['fullText'] := bQuery.FieldByName('fullText').AsVariant ;
aQuery.FieldValues['fullText'] := bQuery.FieldValues['fullText'];
aQuery.FieldValues['Analysis'] := bQuery.FieldByName('Analysis').AsString ;
aQuery.FieldValues['Analysis'] := bQuery.FieldValues['Analysis'];
aQuery.FieldValues['Debate'] := bQuery.FieldByName('Debate').AsVariant ;
aQuery.FieldValues['Debate'] := bQuery.FieldValues['Debate'];
aQuery.FieldValues['FactExc'] := bQuery.FieldByName('FactExc').AsVariant ;
aQuery.FieldValues['FactExc'] := bQuery.FieldValues['FactExc'];
aQuery.FieldValues['key'] := Id ;
aQuery.Post ;
foxelf
初階會員


發表:9
回覆:42
積分:30
註冊:2003-03-05

發送簡訊給我
#9 引用回覆 回覆 發表時間:2009-08-05 13:50:44 IP:118.168.xxx.xxx 訂閱
Stallion你好
資料已經可以正確的新增到資料庫了,萬分感謝
系統時間:2024-04-26 1:02:56
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!