以下為本站文章分類清單

  1. AJAXspacer
  2. ASPspacer
  3. CSSspacer
  4. Javascriptspacer
  5. Windows 應用程式spacer
  6. 網頁設計
  7. 評論、短文、雜文spacer
  8. 版主spacer
  9. 最新回應spacer

以下為本頁本文內容

MS-SQL2000 儲存 UTF-8 的亂碼問題

7/27 08' icon

錯誤的情況是以 utf-8 編碼的前台頁面,存入 MS-SQL 2000 後,部份 utf-8 字碼會變亂碼。以我的主機而言,存入部份簡體字時,就是亂碼。根據微軟的官方說法,是 unicode 字元不同所導致。

原因是找到了,但官方說法中,並沒有提出很有效的解決方案。先來看發生的情況:

會發生亂碼的情況:

不會發生亂碼的情況:

也就是說,如下語法,可能會發生亂碼情況:

insert into member (memberID,memberName) Values ('Audi','王小东')

這個時候,MS-SQL 中的資料,就可能變成「王小?」,同樣情況也發生在使用 update 更新資料列時。

而如果是以 Recordset 方式新增,則不會發生亂碼,如下:

objRec.AddNew
objRec("memberID")="Audi"
objRec("memberName")="王小东"
objRec.Update

如果是用這個方法,只要執行寫入資料庫的頁面,設定好編碼語系,多半就沒有問題。

可行的解決方案:

根據一份非官方說法,加上實作測試的結果,有以下內容,你可以考慮加在頁面中:

以上是兩個很基本的設定,但仍無法解決問題,因為這個亂碼問題來自 MS-SQL 本身,所以你在頁面中再怎麼使力,完全沒用,我找到了一條方案,各位不妨試試,我的實作成功而有用,只不過花了很多時間,改了上百支程式就是了!

方法是:把 insert into 及 update 語法中傳值的部份,加上「前置詞 N」,有興趣的人,可以查看微軟官方文件

也就是修正成以下寫法:

insert into member (memberID,memberName) Values (N'Audi',N'王小东')

使用 update 時,也比照辦理,好了!祝你順利!

以下為文章回應區

同意轉載,不過麻煩看一下轉載需知

Umanizzare presidios   2017/11/13 下午 02:05:00

The other day, while I was at work, my sister stole my iphone and tested to see if it
can survive a thirty foot drop, just so she can be a youtube sensation. My
iPad is now broken and she has 83 views. I know this is totally off topic but I had to share it
with someone!

Lelio Vieira Carneiro Junior   2017/11/10 上午 08:31:00

After checking out a few of the blog articles on your web
page, I truly appreciate your way of blogging. I book-marked it to my bookmark site list and will
be checking back in the near future. Please visit my website too and let me know what you think.

How do you prevent Achilles tendonitis?   2017/9/1 上午 12:32:00

Heya i am for the first time here. I found this board and I find It really useful & it
helped me out a lot. I hope to give something back and help others like you helped me.

How do you strengthen your Achilles tendon?   2017/8/4 上午 11:34:00

I was recommended this web site by my cousin. I'm not sure whether this post is written by him
as no one else know such detailed about my difficulty.
You're wonderful! Thanks!

How do you get Achilles tendonitis?   2017/7/31 上午 11:49:00

I really like reading through a post that will make
men and women think. Also, thanks for allowing for me
to comment!

madelinwean.snack.ws   2017/7/31 上午 01:55:00

Terrific post however , I was wanting to know if you could write a litte more on this topic?
I'd be very grateful if you could elaborate a little bit further.

Appreciate it!

Can you stretch to get taller?   2017/7/27 下午 11:59:00

Hi! This post could not be written any better! Reading this post reminds me of
my good old room mate! He always kept chatting about this.
I will forward this page to him. Fairly certain he will have a good read.

Thanks for sharing!

What causes the heels of your feet to burn?   2017/7/21 上午 08:26:00

You have made some decent points there. I checked on the
internet for additional information about the issue and found most
individuals will go along with your views on this web site.

manicure   2017/5/4 上午 05:18:00

I am in fact grateful to the owner of this site who has shared
this fantastic post at at this time.

manicure   2017/4/11 下午 06:20:00

Everything is very open with a very clear description of the issues.
It was definitely informative. Your site is useful.
Thank you for sharing!

replica watches   2011/2/12 下午 04:00:00

求解中in

archer   2009/4/18 下午 03:16:00

我也遇到了這個問題,一直到現在都無解,
看了您的方法後,也覺得要改幾佰支程式,也不想解了,
聽說把資料庫升級到2005應該可以較簡單吧,
但我也還沒有去做,還不知是否可行

給個回應
姓名:
佈落格網址:
  如果您是要發問問題, 最好有個問題測試的網址, 這樣比較容易找到您問題所在, 謝謝
內容: