Library tutorials & articles

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
   
   %>

Comments

  1. 01 Jan 1999 at 00:00

    This thread is for discussions of ADO and Unicode.

Leave a comment

Sign in or Join us (it's free).

David Nishimoto 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 include a wo...
AddThis

Related podcasts

  • Java Posse #213 - Newscast for Oct 23rd 2008

    Newscast for Oct 23rd 2008 Fully formatted shownotes can always be found at http://javaposse.com The Android project has been released as open source, beating the rumored launch date for the source code by several months http://source.android.com/ And, Gizmodo and ZDNet both offer in-depth ...

We'd love to hear what you think! Submit ideas or give us feedback