Cannot "Insert" Chinese Char

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • hao

    #1

    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


  • Jerry III

    #2
    Re: Cannot "Insert&qu ot; Chinese Char

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

    Jerry

    "hao" <phaomisc@hotma il.com> wrote in message
    news:eRUl2e1ZDH A.2520@TK2MSFTN GP09.phx.gbl...[color=blue]
    > 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
    >
    >[/color]


    Comment

    • hao

      #3
      Re: Cannot &quot;Insert&qu ot; 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" <jerryiii@hotma il.com> wrote in message
      news:ObRcf$2ZDH A.2932@tk2msftn gp13.phx.gbl...[color=blue]
      > How about posting those errors you were getting? We're not psychic...
      >
      > Jerry
      >
      > "hao" <phaomisc@hotma il.com> wrote in message
      > news:eRUl2e1ZDH A.2520@TK2MSFTN GP09.phx.gbl...[color=green]
      > > 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
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • hao

        #4
        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" <jerryiii@hotma il.com> wrote in message
        news:ObRcf$2ZDH A.2932@tk2msftn gp13.phx.gbl...[color=blue]
        > How about posting those errors you were getting? We're not psychic...
        >
        > Jerry
        >
        > "hao" <phaomisc@hotma il.com> wrote in message
        > news:eRUl2e1ZDH A.2520@TK2MSFTN GP09.phx.gbl...[color=green]
        > > 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
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Jerry III

          #5
          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.CommandTe xt = "INSERT INTO Table1(Field1, Field2) VALUES(?, ?)";

          dbCmd.Parameter s.Add("@Field1" , FieldValue1);
          dbCmd.Parameter s.Add("@Field2" , YourChineseWord s);

          dbCmd.ExecuteNo nQuery();

          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" <phaomisc@hotma il.com> wrote in message
          news:eJ21fa4ZDH A.1832@TK2MSFTN GP10.phx.gbl...[color=blue]
          > The database I used is Access and I know if I use SQL Server, I should add[/color]
          a[color=blue]
          > '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" <jerryiii@hotma il.com> wrote in message
          > news:ObRcf$2ZDH A.2932@tk2msftn gp13.phx.gbl...[color=green]
          > > How about posting those errors you were getting? We're not psychic...
          > >
          > > Jerry
          > >
          > > "hao" <phaomisc@hotma il.com> wrote in message
          > > news:eRUl2e1ZDH A.2520@TK2MSFTN GP09.phx.gbl...[color=darkred]
          > > > 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
          > > >
          > > >[/color]
          > >
          > >[/color]
          >
          >[/color]


          Comment

          Working...