473,748 Members | 5,242 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Store Chinese Text

YAN
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.Unicod e.getByte, and i would like to use
in this way:
Dim source As Byte() = System.Text.Enc oding.Unicode.G etBytes("ä¸*国 ")

After i get the Byte Array, how can i store the array by INSERT SQL statement?
Jul 21 '05 #1
3 1956
Hi YAN,

Use an SqlParameter to assign the byte array to the insert statement.

--
Happy Coding!
Morten Wennevik [C# MVP]
Jul 21 '05 #2
YAN
Hi Morten Wennevik,

Thanks for ur reply.

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

YAN

"Morten Wennevik" wrote:
Hi YAN,

Use an SqlParameter to assign the byte array to the insert statement.

--
Happy Coding!
Morten Wennevik [C# MVP]

Jul 21 '05 #3
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( "@MyParamet er",
OleDbType.Binar y);
param1.Value = source;

OleDbCommand insertCommand = new OleDbCommand();
insertCommand.C ommandText = "INSERT INTO MyTable Values(@MyParam eter)";
insertCommand.P arameters.Add(p aram1);

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.

--
Happy Coding!
Morten Wennevik [C# MVP]
Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3185
by: Kobi Lurie | last post by:
Hello all, I'm trying to make a simple script beginner level script, with just functions. it uses the functions: file_get_contents substr taking into an array the text substr took then array_count_values
1
1473
by: YAN | last post by:
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()
3
2000
by: Antonio | last post by:
Hi, I want to read an html page written in chinese and store it in a file having extension .aspx , I'm not sure where is the problem, I use the following lines of code: String sAddress = "http://babelfish.altavista.com/babelfish/trurl_pagecontent?lp=en_zh&trurl=http://www.etantonio.it/EN/index.aspx" ; WebRequest req = WebRequest.Create(sAddress); WebResponse result = req.GetResponse();
1
2364
by: Anthony Liu | last post by:
I believe that topic related to Chinese processing was discussed before. I could not dig out the info I want from the mail list archive. My Python script reads some Chinese text and then split a line delimited by white spaces. I got lists like
8
11983
by: pabv | last post by:
Hello all, I am having a few issues with encoding to chinese characters and perhaps someone might be able to assist. At the moment I am only able to see chinese characters when displayed as part of a datagrid. When an input textbox is displayed it does not display chinese characters, but rather the unicode characters stored in the mssql 2000 server backend.
7
4312
by: c.verma | last post by:
I have a web application. There is a page which has a datagrid on it.The datagrid displays the data that comes from SAP. SAP sends the chinese characters to this grid. Before I display CHinese charactes, I have to use the following code to let it display on the web page: Public Function ToSCUnicode(ByVal str As String) As String Dim enc1252 As System.Text.Encoding = System.Text.Encoding.GetEncoding(1252) Dim arrByte_GBK As Byte() Dim...
3
318
by: YAN | last post by:
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?
0
4103
by: kennymce | last post by:
Hi, I'm having trouble localizing my Oracle 9.2 / ASP web application for our Chinese-speaking users. My Oracle 9.2 Database has NLS_NCHAR_CHARACTERSET set to AL16UTF16. I've set up a test table thus: CREATE TABLE "TBL_TEST_CH"
4
4761
by: Sebastian.Pawlus | last post by:
Hi, I have a problem with Chinese words coded in utf-8. I need to display Chinese marks/words with use of GD or IMagick libs. Chinese text that I need to display is written as plain text in .txt file. I'm not pasting that text inside code. When I'm using only read and echo in PHP. Everything looks fine: example: <?php
0
9534
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8239
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4597
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4867
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2777
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2211
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.