Store Chinese Text

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

Guest

my database (mysql) would be used to store Simplified Chinese and Traditional
Chinese, so i would like to store the text as unicode to the database.

I know there is a function Encoding.Unicode.getByte, and i would like to use
in this way:
Dim source As Byte() = System.Text.Encoding.Unicode.GetBytes("中国")

After i get the Byte Array, how can i store the array by INSERT SQL statement?
 
Hi YAN,

Use an SqlParameter to assign the byte array to the insert statement.
 
Hi Morten Wennevik,

Thanks for ur reply.

However, can u kindly give me an example, i have no idea about this, THANKS

YAN
 
Hi YAN,

Sorry I couldn't reply earlier. Seeing as you use mysql you would
probably need to use OleDbParameter with an OleDbCommand.

You would typically do something like this (c#)

OleDbParameter param1 = new OleDbParameter("@MyParameter",
OleDbType.Binary);
param1.Value = source;

OleDbCommand insertCommand = new OleDbCommand();
insertCommand.CommandText = "INSERT INTO MyTable Values(@MyParameter)";
insertCommand.Parameters.Add(param1);

Note that this code isn't tested and may not be entirely correct.

Note also, thay you may not be able to use named parameters in the insert
text, in which case I believe you need to use ? as in "INSERT INTO MyTable
Values(?)" and the parameters need to be added to the command in the
proper sequence.
 
Back
Top