Professional Web Applications Themes

Cannot "Insert" Chinese Char - ASP.NET General

Hi, all When I use ASP to insert an record to a database, I got some errors and can not insert any value with Chinese Char. The only way I can do that is use "rst1.Addnew...rst1.update". Anyone know why? thx hao...

  1. #1

    Default Cannot "Insert" Chinese Char

    Hi, all

    When I use ASP to insert an record to a database, I got
    some errors and can not insert any value with Chinese Char.
    The only way I can do that is use "rst1.Addnew...rst1.update".
    Anyone know why?


    thx

    hao


    hao Guest

  2. #2

    Default Re: Cannot "Insert" Chinese Char

    How about posting those errors you were getting? We're not psychic...

    Jerry

    "hao" <com> wrote in message
    news:phx.gbl... 


    Jerry Guest

  3. #3

    Default Re: Cannot "Insert" Chinese Char

    Hi Jerry,

    If I use "INSERT INTO ...", the error message is :
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
    [Microsoft][ODBC Microsoft Access Driver] Syntax error in string in query
    expression '''. /oa/send.asp, line 199


    If I use "response.write" to track the sql string, I found the string was
    terminated by the first of the Chinese Char(no Chinese Char can be read)
    like this:

    The Original SQL string:
    INSERT INTO Table1(Field1, Field 2) VALUE('" & FieldValue1 & "', '" &
    MyChineseWords & "')"

    I got this result:
    INSERT INTO Table1(Field1, Field 2) VALUE('abc', '

    which the second field is my Chinese Char. No idea why the string
    terminated.


    If I use "rs.AddNew...." no error message and only a null value saved in the
    table. I use "response.write" to
    track the value before save to the table, it's still empty.

    Lokks like the value MyChineseWords has some symbol and the system think
    it's the end of string. I get MyChineseWords from a text form area that
    input by user. There is no problem which English Charactor, only in Chinese.


    hao



    "Jerry III" <com> wrote in message
    news:ObRcf$phx.gbl... 
    >
    >[/ref]


    hao Guest

  4. #4

    Default One more

    The database I used is Access and I know if I use SQL Server, I should add a
    'N' before it
    to indicate the unicode. But I do not know how to do in Access. Seems the
    'N' does not work
    in Access.


    hao



    "Jerry III" <com> wrote in message
    news:ObRcf$phx.gbl... 
    >
    >[/ref]


    hao Guest

  5. #5

    Default Re: One more

    I've never worked with Access, so I'm not sure if it even supports Unicode
    strings but my suggestion would be to use Command object and add your
    strings as parameters, like this (I suppose the space between Field and 2
    and using VALUE instead of VALUES were just typos in your other post):

    dbCmd.CommandText = "INSERT INTO Table1(Field1, Field2) VALUES(?, ?)";

    dbCmd.Parameters.Add("Field1", FieldValue1);
    dbCmd.Parameters.Add("Field2", YourChineseWords);

    dbCmd.ExecuteNonQuery();

    If that doesn't work then Access doesn't support Unicode as it is. In that
    case you might have to encode your Unicode strings to UTF-8 before inserting
    and remembering to decode them when reading.

    Jerry

    "hao" <com> wrote in message
    news:phx.gbl... 

    > >
    > >[/ref]
    >
    >[/ref]


    Jerry Guest

Similar Threads

  1. New Text Frames Default to "Endnote Reference" Char Style!
    By Kalavinka@adobeforums.com in forum Adobe Indesign Windows
    Replies: 2
    Last Post: July 15th, 01:30 AM
  2. Replies: 5
    Last Post: September 9th, 12:42 PM
  3. FreeHand 10:Converting Chinese Text to paths become "garbish"
    By howwow webforumsuser@macromedia.com in forum Macromedia Freehand
    Replies: 0
    Last Post: July 20th, 11:26 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139