store chinese again

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

    #1

    store chinese again

    i cannot store unicode in thie way, please help!

    Dim souce As Byte() = System.Text.Enc oding.Unicode.G etBytes("CHINES E")
    Dim sSql As String = "insert into tblpitems (fldItmDesc1) values (@a)"
    g_dbCommand.Com mandText = sSql
    Dim paramData As MySqlParameter = New MySqlParameter( "@a",
    ByteFX.Data.MyS qlClient.MySqlD bType.VarChar)
    paramData.Value = souce
    g_dbCommand.Par ameters.Add(par amData)
    DBConnection.Ex ecuteNonQuery()

    i store the string as "System.Byt e[]", what can i do?
  • Jon Skeet [C# MVP]

    #2
    Re: store chinese again

    YAN <YAN@discussion s.microsoft.com > wrote:[color=blue]
    > i cannot store unicode in thie way, please help!
    >
    > Dim souce As Byte() = System.Text.Enc oding.Unicode.G etBytes("CHINES E")
    > Dim sSql As String = "insert into tblpitems (fldItmDesc1) values (@a)"
    > g_dbCommand.Com mandText = sSql
    > Dim paramData As MySqlParameter = New MySqlParameter( "@a",
    > ByteFX.Data.MyS qlClient.MySqlD bType.VarChar)
    > paramData.Value = souce
    > g_dbCommand.Par ameters.Add(par amData)
    > DBConnection.Ex ecuteNonQuery()
    >
    > i store the string as "System.Byt e[]", what can i do?[/color]

    You've specified that it's a VarChar, which means you should specify a
    string, not a byte array.

    You really shouldn't *need* to do any encoding/decoding yourself at
    all. Are you sure your MySql database has been set up to use Unicode?
    (I don't know whether it does by default or not.)

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    Working...