ADO and Unicode

submit_to_database.asp

  • The session.codepage must be set to 65501. This session codepage is support only in Internet Information Server 5.0 (IIS 5.0).
  • Two oracle stored procedures used to add and update the unicode data need to be created.
  • An Active Data Object (ADO) Command Object must be instantiated. ADO command object input parameters must be used to send the unicode data. Binding between a command object parameter and UTF8 string is accomplished as follows: The type parameter must be adVarWChar (unicode string null terminated) .
  • NLS_LANG must be change to AMERICAN_AMERICA.UTF8 in the Windows registry.
  • The 8.1.7.2 Oracle ODBC Driver must be download from Oracle and installed on the Server Machine. You must signup as a member of the Oracle Technology Network (OTN) to download the ODBC driver.
  • Setup a ODBC Data Source Name (DSN) referencing the 8.1.7.2 Oracle driver.

<%@Language=VBScript%>
   <%
   option explicit
   >    
   <--#INCLUDE FILE="adovbs.inc"-->
   <%
   Dim cnn,rs,strSQL,cmd
   Dim sCode_Point
   Dim sUnicode_Number

   session.CodePage=65001 'UTF-8 Codepage supported only in iis5.0

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

   sCode_Point=request("code_point")
   sUnicode_Number=request("unicode_number")

   if sUnicode<>"" and sCode_Point<>"" then
       set rs=nothing

       strSQL ="select unicode from unicode_test where unicode_number='" & sUnicode_Number & "'"
       
       set rs=cnn.Execute(strSQL)
       
       if rs.EOF THEN
           set cmd=Server.CreateObject("ADODB.Command")
           cmd.ActiveConnection=cnn
           cmd.CommandText="add_unicode"
           cmd.CommandType=adCmdStoredProc
           cmd.Parameters.append cmd.CreateParameter("@p_code_point",adVarWChar,adParamInput,200,sCode_Point)
           cmd.Parameters.append cmd.CreateParameter("@p_unicode_number",adVarChar,adParamInput,50,sUnicode_Number)
           
           cmd.execute
       else
           set cmd=Server.CreateObject("ADODB.Command")
           cmd.ActiveConnection=cnn
           cmd.CommandText="update_unicode"
           cmd.CommandType=adCmdStoredProc
           cmd.Parameters.append cmd.CreateParameter("@p_code_point",adVarWChar,adParamInput,200,sCode_Point)
           cmd.Parameters.append cmd.CreateParameter("@p_unicode_number",adVarChar,adParamInput,50,sUnicode_Number)
               
           cmd.Execute
       end if
       Response.Redirect("database_results.asp&unicode_number=" & sUnicode_Number &"&code_point="&sCode_Point)
   else
       Response.Write "
Both the unicode characters and code are required"
   end if
   
   %>

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.

“Beware of bugs in the above code; I have only proved it correct, not tried it.” - Donald Knuth