store chinese again

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i cannot store unicode in thie way, please help!

Dim souce As Byte() = System.Text.Encoding.Unicode.GetBytes("CHINESE")
Dim sSql As String = "insert into tblpitems (fldItmDesc1) values (@a)"
g_dbCommand.CommandText = sSql
Dim paramData As MySqlParameter = New MySqlParameter("@a",
ByteFX.Data.MySqlClient.MySqlDbType.VarChar)
paramData.Value = souce
g_dbCommand.Parameters.Add(paramData)
DBConnection.ExecuteNonQuery()

i store the string as "System.Byte[]", what can i do?
 
YAN said:
i cannot store unicode in thie way, please help!

Dim souce As Byte() = System.Text.Encoding.Unicode.GetBytes("CHINESE")
Dim sSql As String = "insert into tblpitems (fldItmDesc1) values (@a)"
g_dbCommand.CommandText = sSql
Dim paramData As MySqlParameter = New MySqlParameter("@a",
ByteFX.Data.MySqlClient.MySqlDbType.VarChar)
paramData.Value = souce
g_dbCommand.Parameters.Add(paramData)
DBConnection.ExecuteNonQuery()

i store the string as "System.Byte[]", what can i do?

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.)
 
Back
Top