Unicode Error in C#

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New; color:blue string<span style="font-size:10.0pt; font-family:Courier New query =
<span style="color:#A31515 "SELECT name, address FROM licence";
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal; text-autospace:none

<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New; color:green //Create MySql Command
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New; color:#2B91AF MySqlCommand<span style="font-size:10.0pt; font-family:Courier New cmd =
<span style="color:blue new <span style="color:#2B91AF MySqlCommand(query, connection);
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal; text-autospace:none

<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New; color:green //Create a data reader and Execute the command
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New; color:#2B91AF MySqlDataReader<span style="font-size:10.0pt; font-family:Courier New dataReader = cmd.ExecuteReader();
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal; text-autospace:none

<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New AddCol(<span style="color:#A31515 "<span style="font-size:10.0pt; font-family:Myanmar3,serif; color:#A31515 အမည်<span style="font-size:10.0pt; font-family:Courier New; color:#A31515 ",
"string"<span style="font-size:10.0pt; font-family:Courier New ); // utf-8 column name.
<span style="font-size:10.0pt; line-height:115%; font-family:Courier New AddCol(<span style="color:#A31515 "<span style="font-size:10.0pt; line-height:115%; font-family:Myanmar3,serif; color:#A31515 လိပ်စာ<span style="font-size:10.0pt; line-height:115%; font-family:Courier New; color:#A31515 "<span style="font-size:10.0pt; line-height:115%; font-family:Courier New ,
<span style="color:#A31515 "string"); // utf-8 column name.
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New; color:green //Read the data and store them in the list
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New; color:blue while<span style="font-size:10.0pt; font-family:Courier New (dataReader.Read())
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New {
<p style="margin-bottom:0in; margin-bottom:.0001pt; text-indent:.5in; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New; color:#2B91AF DataRow<span style="font-size:10.0pt; font-family:Courier New dataRow = dataTable.NewRow();
<p style="margin-bottom:0in; margin-bottom:.0001pt; text-indent:.5in; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New dataRow[0] = dataReader[<span style="color:#A31515 "name"].ToString();
<p style="margin-bottom:0in; margin-bottom:.0001pt; text-indent:.5in; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New dataRow[1] = dataReader[<span style="color:#A31515 "address"].ToString();
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New }
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal; text-autospace:none

<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New; color:green //close Data Reader
<span style="font-size:10.0pt; line-height:115%; font-family:Courier New dataReader.Close();
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New dataColumn.ColumnName =
<span style="color:#A31515 "<span style="font-size:10.0pt; font-family:Myanmar3,serif; color:#A31515 အမည်<span style="font-size:10.0pt; font-family:Courier New; color:#A31515 "<span style="font-size:10.0pt; font-family:Courier New ;
// utf-8 column name.

<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New; color:blue public<span style="font-size:10.0pt; font-family:Courier New
<span style="color:blue void AddCol(<span style="color:blue string colname,
<span style="color:blue string dataType)
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New {
<p style="margin-bottom:0in; margin-bottom:.0001pt; text-indent:.5in; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New; color:#2B91AF DataColumn<span style="font-size:10.0pt; font-family:Courier New dataColumn =
<span style="color:blue new <span style="color:#2B91AF DataColumn();
<p style="margin-bottom:0in; margin-bottom:.0001pt; text-indent:.5in; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New dataColumn.ColumnName = colname;
<p style="margin-bottom:0in; margin-bottom:.0001pt; text-indent:.5in; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New; color:blue switch<span style="font-size:10.0pt; font-family:Courier New (dataType)
<p style="margin-bottom:0in; margin-bottom:.0001pt; text-indent:.5in; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New {
<p style="margin-bottom:0in; text-indent:.5in; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New; color:blue case<span style="font-size:10.0pt; font-family:Courier New
<span style="color:#A31515 "int":
<p style="margin-bottom:0in; text-indent:.5in; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New dataColumn.DataType = <span style="color:blue
typeof(<span style="color:#2B91AF Int32);
<p style="margin-bottom:0in; text-indent:.5in; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New; color:blue break<span style="font-size:10.0pt; font-family:Courier New ;
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New

<p style="margin-bottom:0in; line-height:normal; text-autospace:none <span style="font-size:10.0pt; font-family:Courier New; color:blue case<span style="font-size:10.0pt; font-family:Courier New
<span style="color:#A31515 "double":
<p style="margin-bottom:0in; line-height:normal; text-autospace:none <span style="font-size:10.0pt; font-family:Courier New dataColumn.DataType =
<span style="color:blue typeof(<span style="color:blue double);
<p style="margin-bottom:0in; line-height:normal; text-autospace:none <span style="font-size:10.0pt; font-family:Courier New; color:blue break<span style="font-size:10.0pt; font-family:Courier New ;
<p style="margin-bottom:0in; line-height:normal; text-autospace:none
<p style="margin-bottom:0in; line-height:normal; text-autospace:none <span style="font-size:10.0pt; font-family:Courier New; color:blue default<span style="font-size:10.0pt; font-family:Courier New :
<p style="margin-bottom:0in; line-height:normal; text-autospace:none <span style="font-size:10.0pt; font-family:Courier New dataColumn.DataType =
<span style="color:blue typeof(<span style="color:blue string);
<p style="margin-bottom:0in; line-height:normal; text-autospace:none <span style="font-size:10.0pt; font-family:Courier New; color:blue break<span style="font-size:10.0pt; font-family:Courier New ;
<p style="margin-bottom:0in; line-height:normal; text-autospace:none <span style="font-size:10.0pt; font-family:Courier New }
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New

<p style="margin-bottom:0in; margin-bottom:.0001pt; text-indent:.5in; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New dataTable.Columns.Add(dataColumn);
<span style="font-size:10.0pt; line-height:115%; font-family:Courier New }
<span style="font-size:10.0pt; line-height:115%; font-family:Courier New // Using utf-8 encoding column name output error see figure.
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New AddCol(<span style="color:#A31515 "<span style="font-size:10.0pt; font-family:Myanmar3,serif; color:#A31515 အမည်<span style="font-size:10.0pt; font-family:Courier New; color:#A31515 ",
"string"<span style="font-size:10.0pt; font-family:Courier New ); // utf-8 column name.
<span style="font-size:10.0pt; line-height:115%; font-family:Courier New AddCol(<span style="color:#A31515 "<span style="font-size:10.0pt; line-height:115%; font-family:Myanmar3,serif; color:#A31515 လိပ်စာ<span style="font-size:10.0pt; line-height:115%; font-family:Courier New; color:#A31515 "<span style="font-size:10.0pt; line-height:115%; font-family:Courier New ,
<span style="color:#A31515 "string"); // utf-8 column name.
<span style="font-size:10.0pt; line-height:115%; font-family:Courier New <img alt="" src="http://social.msdn.microsoft.com/Forums/getfile/193723 <span style="font-size:10.0pt; line-height:115%; font-family:Courier New <br/>

<span style="font-size:10.0pt; line-height:115%; font-family:Courier New // Using ascii encoding column name output correct answer see figure.
<p style="margin-bottom:0in; margin-bottom:.0001pt; line-height:normal; text-autospace:none
<span style="font-size:10.0pt; font-family:Courier New AddCol(<span style="color:#A31515 "name", "string"); // ascii column name.
<span style="font-size:10.0pt; line-height:115%; font-family:Courier New AddCol(<span style="color:#A31515 "address",
<span style="color:#A31515 "string"); // ascii column name.
<span style="font-size:10.0pt; line-height:115%; font-family:Courier New <img alt="" src="http://social.msdn.microsoft.com/Forums/getfile/193724 <span style="font-size:10.0pt; line-height:115%; font-family:Courier New <br/>




View the full article
 

Similar threads

D
Replies
0
Views
97
Donald Uko
D
J
Replies
0
Views
88
JuanC_LopGar97
J
A
Replies
0
Views
158
ANIL AYDINALP
A
K
Replies
0
Views
220
Khan345
K
Back
Top