<p>I have a database in ISO-8859-2 format, but I need to create XML in UTF-8. This means that I must encode the database before prinitng in UTF-8.  I know very little about ASP.Net, so I'm hoping someone can help.</p>

<p>In PHP I would do something like this:</p>

<pre><code>db_connect();
mysql_query("SET NAMES 'UTF8'");
mysql_query("SET character_set_client='UTF8'");
</code></pre>

<p>This is my ASP.Net code for database connection:</p>

<pre><code> 'CONNECTION TO DATABASE
 dim dbconn,sql,dbcomm
 dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" &amp; _
      "Data Source=" &amp; Server.MapPath("../baze/test.mdb"))

 dbconn.Open()          

 sql="SELECT * FROM nekretnine, tipovinekretnina WHERE nekretnine.idtipnekretnine = tipovinekretnina.idtipnekretnine ORDER BY nekretnine.idnekretnine"
 dbcomm=New OleDbCommand(sql,dbconn)
 dbread=dbcomm.ExecuteReader()

 while dbread.Read()
</code></pre>

<p>Where and how do I encode to UTF-8?</p>

[{'answer_id': 71639, 'author': 'Mike Dimmick', 'author_id': 6970, 'author_profile': 'https://Stackoverflow.com/users/6970', 'pm_score': 1, 'selected': False, 'text': "<p>The .NET Framework's internal string type is UTF-16. All database access will convert to UTF-16 so that you can view the data appropriately: the database, or the OLE DB provider, will convert to UTF-16.</p>\n\n<p>The XML writer classes (you <em>are</em> using XmlDocument or XmlWriter, right?) will then convert to UTF-8 on the output.</p>\n\n<p>Basically, you shouldn't need to do anything extra.</p>\n"}, {'answer_id': 71640, 'author': 'Omer van Kloeten', 'author_id': 4979, 'author_profile': 'https://Stackoverflow.com/users/4979', 'pm_score': 3, 'selected': True, 'text': '<p>Assuming you have a value string in <code>str</code>, this is the pure-.NET way of doing this.</p>\n\n<pre><code>var encoding = System.Text.Encoding.GetEncoding("iso-8859-2");\n\nvar bytes = System.Text.Encoding.Convert(encoding, System.Text.Encoding.Default, encoding.GetBytes(str));\n\nvar newString = System.Text.Encoding.Default.GetString(bytes);\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/71578', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/205368/']