dreamweaver

benoitmarcotte
benoitmarcotte used Ask the Experts™
on
I built a form in six languages and it seems that the INSERT statement doesn't work for Arabic, Chinese and Russian. When I type directly in SQL Server, it works fine. So it's not a db issue.. I think. Anyone has an idea? When submitting from the form, I store interrogation marks in the db.
Used Unicode (UTF-8) in the form and nvarchar in the db.

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Try pasting in the code for your insert record action and the html for your form. There's no need to paste the source for the entire page.

Author

Commented:
Thanks a lot for taking a look at this. Let me know if you need anything else
The form action:
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Request.QueryString
End If

The Insert Statement:

If (CStr(Request("MM_insert")) = "formName") Then
  MM_editConnection = MM_cnName_STRING
  MM_editTable = "tableName"
  MM_editRedirectUrl = "fileName"
  MM_fieldsStr  = "q1_1|value|q1_2|value|q1_3|value|q1_4|value|q1_5|value|q1_6|value|q1_7|value|q1_8|value|q1_9|value|q1_10|value|q1_11|value|q1_11Oth|value|q2_1|value|q2_2|value|q2_3|value|q2_4|value|q2_5|value|q2_6|value|q2_7|value|q2_8|value|q2_8Oth|value|q3_1|value|q3_2|value|q3_3|value|q3_4|value|q3_5|value|q3_6|value|q4|value|q5|value|q6|value|q7|value|q8|value|q9|value|q10|value|q10Oth|value|email|value|language|value"
  MM_columnsStr = "reas1|none,1,0|reas2|none,1,0|reas3|none,1,0|reas4|none,1,0|reas5|none,1,0|reas6|none,1,0|reas7|none,1,0|reas8|none,1,0|reas9|none,1,0|reas10|none,1,0|reas11|none,1,0|reasOth|',none,''|act1|none,1,0|act2|none,1,0|act3|none,1,0|act4|none,1,0|act5|none,1,0|acti6|none,1,0|act7|none,1,0|act8|none,1,0|actOth|',none,''|satisf1|none,none,NULL|satisf2|none,none,NULL|satisf3|none,none,NULL|satisf4|none,none,NULL|satisf5|none,none,NULL|satisf6|none,none,NULL|found|none,none,NULL|freq|none,none,NULL|thoughts|',none,''|gender|none,none,NULL|age|none,none,NULL|country|none,none,NULL|occup|none,none,NULL|occupOther|',none,''|followup|',none,''|language|none,none,NULL"
  ' create the MM_fields and MM_columns arrays
  MM_fields = Split(MM_fieldsStr, "|")
  MM_columns = Split(MM_columnsStr, "|")
 
  ' set the form values
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2ž`:
    MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
  Next
  ' append the query string to the redirect URL
  If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
      MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
    Else
      MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
    End If
  End If
End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it
Dim MM_tableValues
Dim MM_dbValues
If (CStr(Request("MM_insert")) <> "") Then
  ' create the sql insert statement
  MM_tableValues = ""
  MM_dbValues = ""
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_formVal = MM_fields(MM_i+1)
    MM_typeArray = Split(MM_columns(MM_i+1),",")
    MM_delim = MM_typeArray(0)
    If (MM_delim = "none") Then MM_delim = ""
    MM_altVal = MM_typeArray(1)
    If (MM_altVal = "none") Then MM_altVal = ""
    MM_emptyVal = MM_typeArray(2)
    If (MM_emptyVal = "none") Then MM_emptyVal = ""
    If (MM_formVal = "") Then
      MM_formVal = MM_emptyVal
    Else
      If (MM_altVal <> "") Then
        MM_formVal = MM_altVal
      ElseIf (MM_delim = "'") Then  ' escape quotes
        MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
      Else
        MM_formVal = MM_delim + MM_formVal + MM_delim
      End If
    End If
    If (MM_i <> LBound(MM_fields)) Then
      MM_tableValues = MM_tableValues & ","
      MM_dbValues = MM_dbValues & ","
    End If
    MM_tableValues = MM_tableValues & MM_columns(MM_i)
    MM_dbValues = MM_dbValues & MM_formVal
  Next
  MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"
  If (Not MM_abortEdit) Then
    ' execute the insert
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = MM_editQuery
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close
    If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If
End If
%>

When declaring the variable MM_ColumnStr = We need to provide instruction N before the string field as in MM_CoumnStr = |fieldName|N',none...
By doing it I got to have my Unicode sent to the db. Not perfect since the N is being sent along with the string. But I think this is a minor problem.

Author

Commented:
Good.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial