ADO and Unicode

database_result.asp

  • The session.codepage must be set to 65501. This session codepage is support only in Internet Information Server 5.0 (IIS 5.0).
  • Retrieval of unicode values must be done through a stored procedure, get_unicode.
  • Optional: You can specify a font family. The font family must support Unicode code points. Here's one font that will work: style="font-family: arial unicode ms"

<%
   Dim cnn, rstUnicode,strSQL,cmd
   Dim sCriteria
   Dim sUnicode_Number
   Dim sCode_Point
   Dim sUnicode_Code_Points
   Dim sOutput

   session.CodePage=65001
   Response.Buffer = True


   sUnicode_Code_Points=""
   Set cnn = Server.CreateObject("ADODB.Connection")
   cnn.Open "your_dsn", "user_name", "password"

   sCode_Point=Request("code_point")
   sUnicode_Number=Request("unicode_number")
   
   set rstUnicode=nothing

   if len(sUnicode_Number)>0 or len(sCode_Point)>0 then

       set cmd=Server.CreateObject("ADODB.Command")
       cmd.ActiveConnection=cnn
       cmd.CommandText="get_unicode"
       cmd.CommandType=adCmdStoredProc
       'Unicode Value
       cmd.Parameters.append cmd.CreateParameter("@p_unicode_number",adVarChar,adParamInput,50,sUnicode_Number)
       'Unicode Code Point
       cmd.Parameters.append cmd.CreateParameter("@p_code_point",adVarWChar,adParamInput,200,sCode_Point)
       cmd.Parameters.append cmd.CreateParameter("@p_output_code_point",adVarWChar,adParamOutput,200,"")

       cmd.Execute

       sUnicode_Code_Points=""&cmd.Parameters("@p_output_code_point").value            
       if sUnicode_Code_Points="" then
           Response.Write "No Records Found"
           Response.end
       end if
   else
       Response.Redirect("unicode.html")
   end if
   
%>

   <HTML>
   <HEAD>
       <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=utf-8">
       <TITLE>
       Unicode Submission Test - Database
       <%=sUnicode_Code_Points%>
       </TITLE>
   </HEAD>

   <BODY>

   <TABLE BORDER=1 WIDTH=700>
   <TR BGCOLOR="lemonchiffon"><TH>Code</TH><TH>Display</TH><TH>Notes</TH></TR>
   <TR>
       <TD><SMALL><%=Len(sUnicode_Code_Points)%></SMALL></TD>
       <TD>You submitted <B><%=Len(sUnicode_Code_Points)%></B> characters.</TD>
       <TD>Length of code point submitted</TD>
   </TR>
   <%
       strSQL="select length(code_point) field_length from unicode_test where unicode='"&sUnicode_Number&"'"
       set rstUnicode= cnn.Execute(strSQL)
   %>
   <%
       if not rstUnicode.eof then
   %>
       <tr>
           
           <TD><SMALL><%=strSQL%></SMALL></TD>
           <TD><%=rstUnicode("field_length")%></TD>
           <TD>Unicode Code Point Length in Database</TD>

       </tr>
   <%
       end if
   %>
   <TR>
       <TD><SMALL><%=rstUnicode("code_point")%></SMALL></TD>
       <TD><%=sUnicode_Code_Points%></TD>
       <TD>Unicode Code Points - Rendered by the Browser</TD>
   </TR>
   </TABLE>

You might also like...

Comments

About the author

David Nishimoto United States

NishiSoft provides Part I of the Information Technology Project collaboration. Sign up and list your IT project tasks, assign task too friends, and get percent complete task.

Part will ...

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The greatest performance improvement of all is when a system goes from not-working to working.” - John Ousterhout