Microsoft KB Archive/261154

= PRB: Visual InterDev Design-Time Controls Corrupt Unicode and Double-Byte Character Set Data =

Article ID: 261154

Article Last Modified on 5/29/2003

-

APPLIES TO

 Microsoft Visual InterDev 6.0 Standard Edition, when used with:  Microsoft Internet Information Server 4.0

 Microsoft Internet Information Services 5.0 

-



This article was previously published under Q261154



SYMPTOMS
Unicode and double-byte character set (DBCS) data become corrupted when you use Visual InterDev Design-Time Controls (DTCs).



CAUSE
Visual InterDev Design-Time Controls use Server.HTMLEncode, an Active Server Pages (ASP) function, to render the control. On Internet Information Services (IIS) 5.0, Server.HTMLEncode incorrectly encodes data that is in a Unicode format, but correctly converts DBCS data. On Internet Information Server (IIS) 4.0 or Personal Web Server (PWS), both Unicode and DBCS data are corrupted.

NOTE: Unicode has been disabled on IIS 4.0 since the release of Microsoft Windows NT Service Pack 4.



Add a Data Connection
NOTE: The data connection in these steps uses the OLE DB Provider for ODBC drivers. However, the same behavior occurs if you use the OLE DB Provider for Microsoft SQL Server.
 * 1) From the Project menu, select Add Data Connection.
 * 2) In the Data Link Properties dialog box, select Microsoft OLE DB Provider for ODBC drivers, and then click Next.
 * 3) Select Use data source name, and then use a data source name that was created to connect to a database.
 * 4) Type a user name and password. Click Test Connection to make sure that you can connect to your database.

Create an ASP page

 * 1) In Project Explorer, right-click the project name, select Add, and then select Active Server Page. Specify a name for the page, and then click Open. A new ASP page opens in the source editor.
 * 2) From the Design-Time Controls toolbox, use a drag-and-drop operation to move a Recordset DTC under the <BODY> tag.
 * 3) Set the Connection option on the Recordset DTC to the name that you gave your Data Connection when you added it to the project. Select a Database Object of Tables. In the Object Name drop-down list box, select a table from your database.
 * 4) From the Design-Time Controls toolbox, use a drag-and-drop operation to move a Textbox DTC to the page under the Recordset DTC.
 * 5) Right-click the Textbox DTC, and click Properties.
 * 6) In the Data section, set the Recordset property to the name of the Recordset DTC that you added in step 2.
 * 7) For the Field property, select the name of a field from your database that contains Unicode or DBCS data. Click OK.NOTE: For IIS 5.0, select a field that contains Unicode data. For IIS 4.0 or PWS, select a field that contains DBCS data.

IIS 4.0 and PWS steps to set up the ASP page to handle Chinese characters
<ol>  Add the ASP CodePage directive to the first line of ASP code as follows: <%@ Language=VBScript CodePage=950%> </li>  Insert the following lines of code after the CodePage directive: <%Session.CodePage = 950%> </li>  Paste the following code in the HTML <HEAD> section of the ASP page. <META HTTP-EQUIV=&quot;Content-Type&quot; CONTENT=&quot;text/html; CHARSET=big5&quot;> </li></ol>

IIS 5.0 steps to set up the ASP page to handle Unicode
<ol>  Add the ASP CodePage directive to the first line of ASP code as follows: <%@ Language=VBScript CodePage=65001%> </li>  Insert the following lines of code after the CodePage directive: <%Session.CodePage = 65001%> </li>  Paste the following code in the HTML <HEAD> section of the ASP page. <META HTTP-EQUIV=&quot;Content-Type&quot; CONTENT=&quot;text/html; CHARSET=utf-8&quot;> </li></ol>

<div class="references_section">