行者

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  17 随笔 :: 1 文章 :: 20 评论 :: 0 引用

2010年8月16日 #

我浑浑噩噩的做了5年的.Net开发,技术感觉不上不下,在很多小公司干过,都是做些很简单的小项目,大概就10来万的项目吧,后来项目有些都单干,感觉很失败。

我其实最怕参加什么面试,主要是理论知识特垃圾,也怕参加什么笔试题,脑经急转弯题。动手能力应该没多大问题,大不了google一下。

刚刚偷跑出去2个小时,参加了一个公司的面试,感觉很不愉快,不知道是我的原因引起的,还是其它。

刚刚进入那个公司,第一感觉就是该公司有些年代了,办公楼看上去有些陈旧,装修也应该上了些年代了。

整个软件公司大约有100来号人,全是青一色的大砖头显示器。(第一感觉工作环境有点恶劣,估计辐射有点大,天气热,能够感觉到外面厕所里面的一些些空气。)

进入了一个小房间里面有2个面试官,面试官先让我简单的做了一下自我介绍,

然后就开始问我问题。

问 :“你做的项目OA中,你觉得最重要的是什么”

答:“应该是工作流吧”

问:“你是如何设计你的工作流的”,

我想:“其实我说的工作流就是网上去抄袭别人项目的工作流,也是很简单的工作流,就是几张表加XML,我该如何回答呢?”

答:".....(Ps 不记得自己说的啥子了)"

问:“你在项目中承担什么角色”

答:“应该算是主要的开发人员吧,有些项目还单干”

问:“你在项目中最擅长什么”

同时这个时候,一个面试官,敲着腿开始吸烟了

我想:“因为我不吸烟,问着感觉很不舒服,感觉这种场合吸烟,也没啥子素质,这是我心里急着想结束这场面试”

答:“应该最喜欢设计吧”,

问:“你设计是依据什么,用到什么工具”。

答:“依据需求规格说明书,设计主要是满足业务模块的需要,用到的设计工具,数据库设计用到powerdesign,UML图这些没画,没做”,

吸烟那个人开始问我问题:“。。。(ps忘记了,感觉很大很空泛,不好回答)”

答:“不知道,(ps :我想走)"

 问:"Vs2005和Vs2008有啥子区别”

答:“我觉得这个问题应该准确的为'.net 2.0和.net 3.5这些有啥子区别吧,....(ps:感觉他们没有技术人员了解.net,他们所以现在想招聘.net team leader)"

问: “你那个学校毕业的,工资目前多少?"

答:“ 。。。(ps:有些疑惑)"

“好我们今天的面试到此结束,再见"

posted @ 2010-08-16 16:14 汪洋怡舟 阅读(396) 评论(3) 编辑

2008年9月12日 #

来自Codeproject

http://www.codeproject.com/KB/sharepoint/ASPNET_to_Sharepoint.aspx

Introduction

There are a lot of ASP.NET web developers who are moving to SharePoint site creation. This article will explain in detail how an ASP.NET webpage developed in Visual Studio can be converted into a SharePoint site. If there is a requirement for a website created in Visual Studio, just the old fashioned way with the code-behind logic and other layers like Data Access and Business Logic, to be converted into a SharePoint site, and still make it work the same way with the same code-behind, you are in the right place. This article deals with right that.

Scenario

There is an ASP.NET website solution that contains three layers viz. Code-Behind Layer, Business-Logic Layer, and the Data-Access Layer. The website has functionality implemented in all these layers. The Business-Logic and the Data-Access layers are in a different Class Library project. We have to convert this website into a SharePoint site. Also, we want to use the same look and feel of the SharePoint site. So, we have to use the SharePoint master page instead of the one that we are having (we can also use our own master page; just that you have to add some default Place Holders that are required for the SharePoint functionalities). In this article, we are dealing with a website with the same look and feel as a SharePoint site.

Steps Overview

There are three steps that are explained in the article which will help you to transform your ASP.NET Web Application into a SharePoint site.

Step1: Add a Web Deployment Project to your website solution that will create a single DLL for the website. This step will give us the code-behind DLL and other dependency DLLs for the website.

Step2: Copy the bin folder items (DLLs) into the SharePoint site, and tweak the web configuration file of the SharePoint site to use the copied DLLs.

Step3: Open your created SharePoint site in SharePoint Designer and import the web pages from our web application and link it to the appropriate DLLs.

Step 1: Adding a web deployment project to your website solution that will create a single DLL for the website

  1. The first step is to make sure you have added the proper namespaces and avoided class name duplications within a namespace before going to step 2.
  2. Add a web deployment project into your website solution. This can be done by right clicking on the website project and choosing 'Add Web Deployment Project' option.
  3. Note: This option will be available once you have installed the Web Deployment Setup.

  4. Add a strong name key to the solution which we will be using to sign all the DLLs.
  5. Now, we have to set the deployment project properties. Right-click on the deployment project and click 'Property Pages'.
  6. Go to the 'Output Assemblies' tab, and choose the 'Merge all assemblies to single assembly' option (this is the default option), and give the assembly name.
  7. Screenshot - output_assembly-Pic1.jpg

  8. Next, go to the Signing tab and choose the 'Enable strong naming' option, and choose the strong name key that you have created in step 3.
  9. Screenshot - signing-pic2.jpg

  10. Also check the option 'Mark the assemblies with AllowPartiallyTrustedCallersAttribute (APTCA)'. This will make the DLL partially trusted, and thus the SharePoint site can use them. Click on OK.
  11. The Data Access, Business Logic, or any other assemblies that are a dependency to the web application must be strong named with a strong name key.
  12. Screenshot - assemblyinfo-pic3.jpg

  13. Also, we have to allow partially trusted callers for the dependency DLLs. This can be done by opening the Assembly.info file of the Class Library project and putting the following line of code as shown above:
  14. [assembly: System.Security.AllowPartiallyTrustedCallers]
  15. Build the deployment project under Release mode (any mode).
  16. Go to the path where the deployment project has put the output. Here, in the bin directory, you will find the web deployment DLL file. If there are any dependency projects such as the Business Layer and the Data-Access Layer, those DLLs also will be copied to this bin folder.

Now, we have the DLLs that can be used in our SharePoint site for using the same functionality as in our ASP.NET site.

Step 2: Copy the bin folder items (DLLs) into the SharePoint site and tweak the web configuration file of the SharePoint site to use the copied DLLs

The next step in our SharePoint site creation is linking the DLLs that we have created in the procedure above into our already existing blank SharePoint site. There are also some changes that are required in our SharePoint site's web.config file (By default found in C:\Inetpub\wwwroot\wss\VirtualDirectories\<PortNo>). Following are the steps that has to be done:

  1. Copy the bin folder contents from your ASP.NET deployment folder into the bin folder of your SharePoint site (usually in C:\Inetpub\wwwroot\wss\VirtualDirectories\<PortNo>\bin).
  2. Open the web.config file of your SharePoint site.
  3. Add the following line in under the <PageParserPath> section:
  4. <PageParserPath VirtualPath="/*" CompilationMode="Always"
        AllowServerSideScript="true" IncludeSubFolders="true" />
  5. Register the assemblies that will be used in the SharePoint site (web deployment DLL which has the code-behind code, the Business Layer and Data Access DLLs) as a SafeControl. For this, add the following under the <SafeControls> section:
  6. <SafeControl Assembly="SampleWebSiteAssembly"
        Namespace="SampleSiteNamespace" TypeName="*" Safe="True" />
  7. Also add all the other dependency DLLs that your site will be using. Note that all these DLLs must be strong named and marked AllowPartiallyTrusted.
  8. Change the trust level from Minimal to Medium by changing the level attribute of the <trust> section from 'WSS_Minimal' to 'WSS_Medium'.
  9. Note: You can also do the following to enable the original errors being shown in the SharePoint site screen for easy error identification. You have to change the mode attribute of the <customErrors> section to Off. Also, change the CallStack attribute of the <SafeMode> section to True.

Step 3: Open your created SharePoint site in SharePoint Designer and import the web pages from our web application

Let us say we have a link in our SharePoint site in the left navigation panel, on the click of which you want to display one of your ASP.NET pages in the content place holder of the SharePoint site. This is what we do:

  1. Open your SharePoint site in the SharePoint Designer (in this article, we are using SharePoint Designer 2007).
  2. Click on File-->Import-->File. This will open the Import dialog box.
  3. Click on 'Add File' and choose the ASPX page that you have created from your local folder. Please note that you have to take the ASPX file from the deployment folder and not the ASPX page that is there in the project. Click OK. This will import the page into your SharePoint site.
  4. Now, double-click on the newly imported page. Click on the Split option in the Design/Split/Code option in the centre pane (bottom left of the pane).
  5. As soon as you do this, you will see in the designer window an error that says: The Master Page file cannot be loaded. This is because the master file that we have used in the project is different from the master page that the SharePoint site uses. You can either import the master page or use SharePoint's default master page. In this article, we are going to use SharePoint's default master page.
  6. Change the 'MasterPageFile' attribute in the Page directive of the web page to a value same as the default.aspx in the SharePoint site, which is ~masterurl/default.master.
  7. Delete the 'CodeFile' attribute from the Page directive as this is only for Visual Studio purposes.
  8. Now, change the ContentPlaceHolderID of the place holders in the ASP.NET page to a relevant SharePoint site place holder. For example, the ContenPlaceHolderID of the main content place holder of the ASP.NET page must be changed to 'PlaceHolderMain'.
  9. After mapping the place holders of the ASP.NET page to that of the SharePoint master page, the page will render in the design view with the default master page.
  10. Now, we have to change the Inherits attribute to add the assembly name. For example, if the namespace is 'SampleSiteNamespace' and the assembly name that the page uses for code-behind is SampleWebSiteAssembly, then we set Inherits="SampleSiteNamespace.SampleWebSiteAssembly", and this assembly must be in the bin of the SharePoint site as added in Step 2 above.
posted @ 2008-09-12 10:41 汪洋怡舟 阅读(212) 评论(1) 编辑

2008年1月21日 #

多國語系的資料處理與整合技術探討

更新日期: 2005 年 3 月 7 日

作者:台灣微軟資料庫講師楊志強

本頁內容
前言 前言
瞭解 Unicode 與多國語系資料處理問題 瞭解 Unicode 與多國語系資料處理問題
介紹 SQL Server 處理多國語系的能力 介紹 SQL Server 處理多國語系的能力
介紹資料處理工具對多國語系統使用技巧 介紹資料處理工具對多國語系統使用技巧
介紹前端開發程式撰寫處理多國語系技巧 介紹前端開發程式撰寫處理多國語系技巧
結論 結論

前言

全球化趨勢下台灣企業逐漸走向國際化,企業間資料的交換處理與程式開發都將面臨如何配合地區性的不同而調整展示語系與如何在同一資料庫中同時處理多種語系資料交換與查詢,這些都是台灣企業面對國際化,資料處理上的重大議題,文章中將介紹 SQL Server 2000 如何處理多國語系的資料能力,包括定序的設定工具的使用技巧,再搭配前端應用程式的開發說明,逐步引導大家如何在多種資料來源的環境中,正確地處理資料儲存與展示。

回到頁首回到頁首

瞭解 Unicode 與多國語系資料處理問題

國際組織 Unicode 學術學會針對每個字元提供唯一的字碼點 (Code Point),其設計目的,是為了涵蓋世界上所有語言的字元。也因此,Unicode 為每個字元提供了一個唯一的編碼,無關於作業平台、程式與語言。Unicode 標準已經被這些工業界的領導們所採用,例如:Apple, HP, IBM, Microsoft, Oracle, SAP, Sun, Sybase, Unisys …,也列入產品的標準如資料庫軟體的 SQL Server , IBM DB2 , Oracle ,Sybase…,作業平台 Microsoft Windows CE, NT, 2000, XP …程式語言的 Java / Visual Studio…,並且,Unicode 是實現 ISO/IEC 10646 的主要方式。Unicode 標準的出現和支援它工具的存在,是近來全球軟體技術最重要的發展趨勢。

Unicode 與編碼的關係

Unicode 不指定字元在記憶體、資料庫與網頁如何呈現,每個字元的顯示必須透過編碼方式進行處理,目前主要使用下列三種編碼結構:UCS-2、UTF-16 和 UTF-8。

UCS-2

在這個機制之下,所有的 Unicode 字元都使用兩個位元組來儲存,透過兩個位元組總共可以提供 65536(2^8*2^8) 的字碼點,UCS-2 是 Microsoft NT 4.0 / SQL 7.0 / SQL 2000 主要編碼機制。如果以兩個位元組表示繁體中文的『強』則表示成 U+5F37,其他文字如簡體中文、日語與韓語在 UCS-2 表示方法如下:

表示成 U+7F51

表示成 U+3048

表示成 U+CC45

UTF -16

UTF-16 針對某些字元使用兩個位元組來進行儲存,其他字元可能用到四個位元組,這是 Windows 2000 使用的主要編碼機制,在 UCS-2 中包含的字元都是屬於 UTF-16 的子集合,其他某些語言的特殊字,如中文字中很罕見,且多半出現在古典文學作品中,或具有歷史意義的字元等,這些字元會被視為替代 (surrogate) 字元,直接以多個位元組儲存在 UTF-16 編碼結構之下,如此可以增加識別 1,048,576 個字元(新增範圍從 U+D800 ~ U+DFFF,1024 Low 字元,1024 High 字元)。SQL Server 2000 使用 UCS-2 儲存,它會將特殊的替代字元視為兩個未定義的 Unicode 字元,在儲存的過程中,當兩兩配對在一起時,便可定義替代字元。如此一來,SQL Server 2000 儲存替代字元時就不會有遺失或損毀的風險。

UTF-8

第三種編碼結構是 UTF-8,它以一到四個位元組之間的可變動長度來儲存 Unicode 資料。許多資料庫程式,像是由 Oracle 和 Sybase 開發的程式,都使用這種編碼結構,SQL Server 2000 針對 XML 資料儲存亦使用 UTF-8 編碼。UTF-8 資料字元沒有固定長度的緣故,所以在處理以下的資料交換時,將有影響

COM 元件使用 UTF-8 資料,須額外轉換成 UCS-2/UTF-16

Windows NT / 2000 核心都是使用 UCS-2 / UTF-16,使用 UTF-8 儲存格式必須透過額外轉換

UTF-8 資料屬於變動資料格式,進行排序、比較和其他字串作業時比 UCS-2 慢

UTF-8 資料屬於變動資料格式,需要額外的儲存空間與記憶體的使用

回到頁首回到頁首

介紹 SQL Server 處理多國語系的能力

儲存 Unicode 資料

SQL Server 2000 處理多國語系時,根據 SQL-92 規範使用 N 代表 National 資料型態,每個字元兩個 Bytes,不受單一定序(Collation)影響可同時支援儲存多國語言,透過下列資料型別,提供定義資料表進行 Unicode 字元資料處理。

NCHAR

固定長度的字元資料,不能超過 4,000 字元

NVARCHAR

變動長度的字元資料,不能超過 4,000 字元

NTEXT

長度可高達 2^30 - 1 (1,073,741,823)

在 SQL Server 2000 中字串函數的處理,可以搭配函數 DATALENGTH 計算出字串位元組數目,LEN 函數計算出字元數。當在 SQL Server 中處理 Unicode 資料時候,特別注意要使用 N 表示 Unicode 的處理,例如新增資料到定義成 NCHAR/NVARCAHR/NTEXT 的欄位時,必須使用以下的寫法

INSERT INTO MY_EMPLOYEES VALUES (N’中文’,N’中文’)

儲存 Non-Unicode 資料

SQL Server 2000 處理一般 Non-Unicode 字元時,每個字元所佔空間與所支援的語系有關,由定序的字碼頁決定。每個字元所佔空間為 1-2 個位元組,例如亞洲語系每個字元使用 2 個位元組,一般英文語系每個字元使用 1 個位元組。一般儲存 Non-Unicode 的字串時可以使用以下的資料型態

CHAR

固定長度的字元資料,不能超過 8,000 字元

VARCHAR

變動長度的字元資料,不能超過 8,000 字元

TEXT

長度可高達 231 - 1 (2,147,483,647 )

一般當 Unicode 資料透過一般字串,插入其中一個非 Unicode 資料型別資料行時,SQL Server 會將資料利用 Windows API 中的 WideCharToMultiByte 與 MultiByteToWideChar 等函數轉換資料型別與資料行定序相關的字碼頁。當字碼頁無法表示字元時,就會以問號 (?) 代替,表示資料已經遺失。資料中若有非預期的字元或問號出現,表示您的資料在某個層次已經從 Unicode 轉換成 Non-Unicode,而在轉換的過程中造成了字元的遺失。再者一般字碼頁決定所支援的語系,例如當字碼頁為 950 表示支援中文的語系,而有些地區僅能選用字碼頁為 0 的 Unicode 字碼支援方式,例如北印度語等。其他相關的字碼頁如下表所示:

語言 字碼頁

簡體中文

936

繁體中文

950

日文

932

韓文

949

Unicode 與 Non-Unicode 儲存方式與效能的比較

Unicode 每個字元使用 2 bytes 進行儲存,所以有以下的特點:

非雙位元組字元集 (DBCS) 仍使用 2 bytes 編碼,需要多一點空間

ODBC (3.6 版或更早的版本) 和資料程式庫 API 無法識別 Unicode

亞洲語言使用Unicode固定 2 位元組編碼,比特定字碼頁指定進行處理有效率,主要原因是字碼頁指定下的資料儲存會有混合長度差異

Non-Unicode字元視 Code Page 決定字元所佔為 1~ 2 bytes

中文、日文等亞洲語言使用 Non-Unicode 時,使用雙位元組字元集 (DBCS) 來儲存字元

亞洲語言使用 Non-Unicode 和 Unicode 間執行儲存作業幾乎沒有差別

非亞洲語言進行 Non-Unicode 排序比 Unicode 快 30%

多國語系對日期時間的處理方式

SQL Server 對日期時間的儲存資料型態分成:DATETIME/SMALLDATETIME 兩種格式,並可透過 CONVERT 函數轉換成各種型態的輸出格式。其中,DATETIME 資料格式支援日期範圍從公曆 (Gregorian calendar) January 1, 1753 到 December 31, 9999,時間準確度為 (1/300) 秒,在資料庫內部儲存以兩個 4 bytes 整數 (Integer) 儲存值。SMALLDATETIME 資料格式支援範圍比較小,從公曆 January 1, 1900 到 June 6, 2079 ,時間準確度以 29.999 秒 區隔,也就是以分為準確度,資料庫內部儲存以兩個 2 bytes 整數 (Integer) 儲存值。

在日期時間轉換成各個國家表示方式時,可以透過 CONVERT() 函數進行轉換,使用方法如下

SELECT CONVERT(data_type , 時間 , 格式)

例如格式 111 表示 Japan 格式,也就是 yyyy/mm/dd,其中也支援回教太陰曆的轉換格式,但是特別注意輸出字串時,必須使用 Unicode 表達,否則會出現轉換失敗的 ??? 號,相關畫面可以參閱下圖所示。

 

定序的觀念

早期的 SQL Server 6.5 尚無支援 Unicode 的字元,透過字碼頁決定所支援的語系處理功能,每一個 SQL Server 6.5 執行個體對應一個字碼頁,例如選擇 CP950 時可以支援中文。SQL Server 7.0 每一個 SQL Server 執行個體支援一個 Unicode 的定序與 Non-Unicode 的定序,其中 Non-Unicode 包含字碼頁與排序順序方式。SQL Server 2000 將字碼頁與定序合成單一設定,可以在執行個體安裝時候選定,也可以在資料庫建立時選定,更可在資料表建立時候個別欄位獨立指定,或是在T-SQL運算式中使用來決定字串的運算方式,例如排列方式、字元大小、腔調差異與全半形比較等。英語語系可以透過定序決定字母的排序、大小寫區隔,非英語語系決定多樣化的資料排序,例如按照筆畫、注音、字元全半形、假名等,定序更攸關索引建立時索引頁的資料排序方式。

SQL Server 2000 中有兩種定序類型可以選擇:Windows 定序和 SQL 定序。Windows 定序根據與 Windows 地區設定相關的規則,來定義排序規則。要進行這項工作,SQL Server 會複製 Windows Server 的排序規則,並將它們套用到對應的 Windows 定序中,透過這個方法,SQL Server 中給定 Windows 2000 定序的字串比較作業,會與執行相同定序之 Windows 版的比較作業相容。但是,因為 Windows Server 2000 之後的 Windows 版本,如 Windows XP 和 Windows Server 2003 使用不同的排序資料表,因此安裝在這些 OS 上 SQL Server 的 Windows 定序,可能會顯示與主機端 OS 不同的排序方式。SQL 定序與 Windows 地區設定無關,提供的目的是與 SQL Server 早期版本的排序順序相容。

透過內建系統函數 COLLATIONPROPERTY 可以判斷出每一個定序的支援字碼頁與地區編號,如果所找出的字碼頁若為0時,表示該定序僅支援 Unicode 的字串處理方式。下圖展示透過內建函數判斷定序所支援的字碼頁與地區編號。


四個定序運用的範圍

SQL Server 2000 的定序的使用方式非常具有彈性,包含以下四個範圍:

系統安裝( Server Collation )

透過 SELECT SERVERPROPERTY('collation')查詢出來執行個體所選定的定序設定,如果當執行個體安裝完畢之後,需要更改執行個體的定序時,必須透過公用程式 RebuildM.exe,才可以重新修改執行個體的定序設定。內定該公用程式所在位置為 C:\Program Files\Microsoft SQL Server\80\Tools\Binn\ rebuildm.exe,作業設定如下。

啟動 Rebuildm.exe 程式畫面

選擇定序的設定畫面

資料庫建立 (Database Collation)

第二階層設定定序的層級是資料庫建立時可以選定,當建立資料庫時內定使用執行個體的定序設定,若需要特殊定序則必須在建立資料庫時,透過下列畫面選定。當完成資料庫建立後,可以透過 SELECT DATABASEPROPERTYEX(‘DBName, ‘collation’) 查詢出來所屬的資料庫的定序設定值。一般情況在 Enterprise Manager 的畫面時,是無法直接修改既定的資料庫定序值,但可以透過 T-SQL 的指定進行資料庫定序的更改,修改指令如下:

ALTER DATABASE Northwind COLLATE Chinese_Taiwan_Bin

一般建立完成後的資料庫定序,無法直接從 Enterprise Manager 畫面修改

資料表欄位 (Column Collation)

第三種層級的定序設定就是在資料表建立時,個別欄位中指定不同的定序,透過這樣的彈性設定可以讓同一個資料表中在一般的 char/varchar/text 資料型態,支援不同語系的字串資料。例如一個跨國企業的訂單彙總表,可以選擇第一個欄位存放簡體中文資料、第二欄位存放繁體中文資料,第三個欄位存放日語資料,透過這樣的彈性設定可以讓資料彙總更具彈性與靈活。下圖可以展示出不同資料欄位定序與多國語系資料設定的技巧。

第一個欄位屬於 Chinese_PRC_Stroke_CI_AS 的定序設定

第二個欄位屬於 Chinese_Taiwan_Stroke_CI_AS 的定序設定

第三個欄位屬於 Japanese_CI_AS 的定序設定

透過 Query Analyzer 可以直接瀏覽不同定序欄位的資料

運算式 ( Expression Collation)

利用 Collate 關鍵字可以在 T-SQL 所撰寫的 Script 中指定定序的使用,例如透過定序指定原先不分字元大小寫的字串,轉換成區分成字元的大小寫;也可以透過定序指定中文字的排序方式,可以依照注音符號或是按照筆畫進行排序等。以下的範例將展示如何透過定序在運算式中改變資料的排序方式,原先的資料如果是一般的 Chinese_Taiwan_Stroke_CI_AS 時,資料輸出是按照比較次序排列,如以下畫面


若是透過定序在排序時改變成按照注音符號進行排序,則出來的結果將有明顯的不同,將依照ㄅㄆㄇㄈ等進行字的排序,如下圖所示

 

回到頁首回到頁首

介紹資料處理工具對多國語系統使用技巧

DTS (資料轉換服務)

當透過 DTS 匯入字元資料時,在伺服器端定義 Unicode 可確保匯入的資料會完整無缺的接收,並適當的儲存。此外,當來源或目的不是 SQL Server 的執行個體時,您必須依靠在呼叫端 ODBC 驅動程式或 OLE DB Provider 的轉譯運作方式,例如如果要將法文 OEM 字碼頁資料,匯入到 SQL Server 1252 字碼頁,且來源電腦未正確執行 1252 字碼頁的轉換,可能造成資料損毀。當使用 Unicode 資料時,「DTS 匯入/匯出精靈」包含特定對話方塊,可能無法正常顯示 Unicode 資料,但是在傳輸期間不會損毀資料。此外透過 Copy SQL Server Objects Task 可以處理不同定序間轉換的問題,可以將資料按照原本的型態進行複製。

Bulk Insert Program 公用程式 / Bulk Insert 指令

複製非 Unicode 資料時,若要防止資料遭到損毀,還可透過 SQL Server BCP 公用程式來達成,方法如下:使用 bcp 將資料匯出到一般檔案。藉由指定 –w 或 –N 命令列旗標 (參閱如下),將該資料會在處理程序中轉換成 Unicode。但是,這個方法仍會遺失來自來源資料但不存在於目的字碼頁的字元。

BCP DB.OWNER.XXX out C:\XXX.txt -w -T -Ssvrname

BCP DB.OWNER.XXX out C:\XXX.txt -N -T -Ssvrname

旗標 意義 附註

-C xxx

字碼頁規範

xxx 指定資料轉換成 ANSI、OEM、RAW (不轉換而直接複製) 或特定的字碼頁號碼。

-N

Unicode 原生格式

針對所有非字元資料,將資料轉換成原生資料庫資料型別,並針對所有字元資料,將資料轉換成 Unicode 字元格式。

-w

Unicode 字元格式

針對所有資料行,將資料轉換成 Unicode 字元資料格式。

透過 T-SQL 的 Bulk Insert 指令時,可以透過 CODEPAGE 與 DATAFILETYPE 的指定,進行多國語系字串資料的搬移,指令說明如下。

BULK INSERT[['database_name'.]['owner'].]{'table_name' FROM 'data_file'}
            [WITH
            (
            [BATCHSIZE[=batch_size]]
            [[,]CHECK_CONSTRAINTS]
            [[,]CODEPAGE[='ACP'|'OEM'|'RAW'|'code_page']]
            [[,]DATAFILETYPE[={'char'|'native'|'widechar'|'widenative'}]]
            
字碼頁的值 描述

OEM (這是預設的運作方式)

資料匯入到 SQL Server 執行個體時,char、varchar 或 text 資料型別的資料行,會從系統 OEM 字碼頁轉換到 SQL Server 字碼頁,相同地,從 SQL Server 執行個體匯出資料時亦然。

ACP

資料匯入到 SQL Server 執行個體時,char、varchar 或 text 資料型別的資料行,會從 ANSI/Windows 字碼頁 (ISO 1252) 轉換到 SQL Server 字碼頁,相同地,從 SQL Server 執行個體匯出資料時亦然。

RAW

不會發生字碼頁間轉換的情形,因此這是最快的選項。

<值>

這代表特定的字碼頁號碼 (例如 850)。

Replication (複寫)

透過 Replication 機制進行資料複寫時,可以在發行集的發行項中屬性頁中[定序],進行指明使用定序相容處理機制,如此資料進行複寫時,可以完整的進行移轉,設定畫面如下所示。

 

回到頁首回到頁首

介紹前端開發程式撰寫處理多國語系技巧

Win32 應用程式

在 Microsoft Visual Basic 應用程式中,字元字串以 UCS-2 編碼結構處理,因此,在這些應用程式和 SQL Server 之間,不需要明確地指定編碼結構的轉換,VB.NET 本身支援多國語系資料的展示,亦無須特別設定。

Web 應用程式

對於以 Web 為基礎的應用程式,您在用戶端 HTML 網頁的 META 屬性之下,指定 CHARSET 碼。例如,如果用戶端的 Unicode 編碼結構是 UTF-8,則指定 CHARSET = utf-8。在伺服器端,使用 session.codepage 屬性或 @codepage 屬性指示詞,指定用戶端的編碼結構。例如,codepage=65001 指定 UTF-8 編碼結構。如果您遵守這些方法,Internet Information Services (IIS) 5.0 或更新版本會正確地將 UTF-8 轉換成 UCS-2,並轉換回來,不需要執行其他動作。


若需處理這個轉換的額外選項,可以在 http://support.microsoft.com/?kbid=232580 取得。

回到頁首回到頁首

結論

多國語系資料處理的重點上必須瞭解資料庫定序影響層面有執行個體安裝設定,更改時必須重建 Master 資料庫;資料庫建立時設定,若要進行修改可以透過 Alter Database 完成;資料表欄位設定,可以運用在多樣字元處理方式或是在 SQL 運算式中使用,可以變化資料展示與查詢方式。對於 Unicode 字串的使用可以在多國語系中簡單化資料的交換與處理,使用 Unicode 必須注意字元的所佔空間,在應用程式的使用上面透過資料庫多國語系功能簡單化前端程式開發。

posted @ 2008-01-21 12:29 汪洋怡舟 阅读(524) 评论(0) 编辑

2007年12月21日 #

 

--1,列出源文件的逻辑名和物理名

RESTORE FILELISTONLY

FROM DISK = 'F:\TempShare\MoveManager\IntegralWeb_db_200612070304.BAK' --备份文件的路径

 

/*

Result:

LogicalName PhysicalName Type FileGroupName Size MaxSize

IntegralAccountingSQL_dat    C:\Data2\integralweb.mdf     D    PRIMARY     229376000     35184372080640

IntegralAccountingSQL_log    C:\Data2\integralweb_log.ldf    L    NULL     516096     35184372080640

*/

 

--2, 恢复数据库, Move后的文件名必须是逻辑名, TO后的路径为此数据库存放的路径和名字(名字自定义)

RESTORE DATABASE IntegralWeb

FROM DISK = 'F:\TempShare\MoveManager\IntegralWeb_db_200612070304.BAK' --备份文件的路径

WITH MOVE 'IntegralAccountingSQL_dat' TO 'E:\Microsoft SQL Server\MSSQL\Data\IntegralWeb.mdf',

MOVE 'IntegralAccountingSQL_log' TO 'E:\Microsoft SQL Server\MSSQL\Data\IntegralWeb.ldf'

posted @ 2007-12-21 11:05 汪洋怡舟 阅读(28) 评论(0) 编辑

2007年10月18日 #

 

using System; 

using System.Configuration; 

using System.IO; 

using System.Web; 

 

namespace SingingEels 



    
public class ErrorLogger 

    


        
public static void LogException(Exception ex) 

        


ErrorLoggerSection configInstance 
= ConfigurationManager.GetSection("WebSiteErrorLogger"as ErrorLoggerSection; 

 

            
if (configInstance != null

            


string myDirectory=HttpContext.Current.Server.MapPath(configInstance.LogFilePath + DateTime.Now.Year.ToString()+"/"+ DateTime.Now.Month.ToString()+"/"); 

string mypath=myDirectory+DateTime.Now.ToShortDateString()+".txt"

if (!Directory.Exists(myDirectory)) 



Directory.CreateDirectory(myDirectory); 

}
 

File.AppendAllText(mypath, 
string.Format("{0:yyyyMMdd_HHmmss} :: {1}{2}{2}", DateTime.Now, ex, Environment.NewLine)); 

 

            }
 

            
else 

            


throw new Exception("Could not find section 'ErrorLoggerSection' in the application configuration file."); 

            }
 

        }
 

    }
 

 

    
// Inherit from "ConfigurationSection" simple enough! 

    
public class ErrorLoggerSection : ConfigurationSection 

    


        
// I only want one property LogFilePath, and I'm 

        
// here telling .NET to look for an attribute in the 

        
// config file called 'logFilePath' to get the value from. 

        [ConfigurationProperty(
"logFilePath", IsRequired = true)] 

        
public string LogFilePath 

        


            
get 

            


                
return (string)base["logFilePath"]; 

            }
 

 

            
set 

            


                
base["logFilePath"= value; 

            }
 

        }
 

    }
 

}
 


Web.config

<?xml version="1.0"?> 

<configuration> 

    
<configSections> 

        
<section name="WebSiteErrorLogger" type="SingingEels.ErrorLoggerSection"/> 

    
</configSections> 

    
<WebSiteErrorLogger logFilePath="~/Log/"/> 

 

    
<system.web> 

        
<compilation debug="true"/> 

    
</system.web> 

 

<system.web> 

<customErrors mode="RemoteOnly" defaultRedirect="~/Error.htm"></customErrors> 

</system.web> 

 

</configuration> 


Global.asax

<%@ Application Language="C#" %> 

 

<script runat="server"> 

 

void Application_Start(object sender, EventArgs e) 



// Code that runs on application startup 

 

}
 

 

void Application_End(object sender, EventArgs e) 



// Code that runs on application shutdown 

 

}
 

 

void Application_Error(object sender, EventArgs e) 



// Code that runs when an unhandled error occurs 

 

Exception err 
= Server.GetLastError().GetBaseException(); 

SingingEels.ErrorLogger.LogException(err); 

 

 

 

}
 

 

void Session_Start(object sender, EventArgs e) 



// Code that runs when a new session is started 

 

}
 

 

void Session_End(object sender, EventArgs e) 



// Code that runs when a session ends. 

// Note: The Session_End event is raised only when the sessionstate mode 

// is set to InProc in the Web.config file. If session mode is set to StateServer 

// or SQLServer, the event is not raised. 

 

}
 

 

</script>

 

 源代码

posted @ 2007-10-18 11:07 汪洋怡舟 阅读(697) 评论(2) 编辑

2007年9月13日 #

摘要: 【IT168技术文档】   SQL SERVER日期格式与多国语言问题(一)   数据库language不同,sql server对日期格式的选择也不同。  数字日期格式   Microsoft® SQL Server™ 2000 允许用指定的数字月份指定日期数据。例如,5/20/97 表示 1997 年 5 月的第 20 天,当使用数字日期格式时,在字符串中以斜杠(/)、连字符(-)或句号...阅读全文
posted @ 2007-09-13 15:44 汪洋怡舟 阅读(852) 评论(1) 编辑

2007年6月7日 #

摘要: /Files/longren629/DelegateDemo.zip1:操作类usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web...阅读全文
posted @ 2007-06-07 17:45 汪洋怡舟 阅读(116) 评论(0) 编辑

2007年4月27日 #

摘要: /Files/longren629/WebSite1.rar在网上找到一个自定义弹出窗口的js(作者:申楠 , 黑旋风 )JScript2.jsvaralternateFrame=null;//生成的iframevaralternateWin=null;window.alert=showAlert;window.confirm=showConfirm;/**//***人机交互窗口,覆盖自带的*/f...阅读全文
posted @ 2007-04-27 14:21 汪洋怡舟 阅读(757) 评论(0) 编辑

2007年3月14日 #

摘要: 参考资料:http://blog.csdn.net/longren629/archive/2005/07/29/438331.aspx http://www.cnblogs.com/freeliver54/archive/2007/01/05/612393.html http://www.cnblogs.com/Terrylee/archive/2006/08/01/Enterprise_Libr...阅读全文
posted @ 2007-03-14 15:21 汪洋怡舟 阅读(1834) 评论(4) 编辑

2007年1月30日 #

posted @ 2007-01-30 09:46 汪洋怡舟 阅读(555) 评论(1) 编辑