473,396 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

C#-APP, odbc .net and MySql: I'm having problems with encodings

3
I'm using dbase MySql with character encoding utf-8. The program is written on C#. IDE - SharpDevelop.
I use odbc to get some string data from dbase, but I get:
either symbols '?' if I don't set the charset to utf8 in my program via connection string or 'SET NAMES 'utf8''
or just strange symbols if I set the charset using one of the ways written above.
I looked in msdn, but I didn't find anything more about how I can set character set for obdc connection. Concerning mysql itself, I've set all charset variables to utf-8.
Expand|Select|Wrap|Line Numbers
  1. private void EstablishConnection()
  2.         {
  3.             string MyConString = "DRIVER={MySQL ODBC 3.51 Driver};" +
  4.                     "SERVER=localhost;" +
  5.                     "DATABASE=building;" +
  6.                     "UID=root;" +
  7.                     "PASSWORD=arksoem;" +
  8.                     "CHARSET=utf8;" +
  9.                     "OPTION=6";
  10.             MyConnection = new OdbcConnection(MyConString);//"DNS=myodbc");
  11.             MyConnection.Open();
  12.             OdbcCommand com = new OdbcCommand("SELECT name FROM building_type",MyConnection);
  13.     //        OdbcCommand com = new OdbcCommand("SET NAMES \'utf8\'",MyConnection);
  14.     //        com.ExecuteNonQuery();
  15.     //        string MyComString = "SELECT name FROM building_type";
  16.     //        com.CommandText = MyComString;
  17.             OdbcDataReader dr = com.ExecuteReader();
  18.             textBox1.Text = "My string. Строка этакая на utf8.";
  19.             listBox1.BeginUpdate();
  20.             while(dr.Read())
  21.             {
  22.                 string str = dr.GetString(0);
  23.                 listBox1.Items.Add(str);
  24.             }
  25.             listBox1.EndUpdate();
  26.             MyConnection.Close();
  27.         }
  28.  
Mar 23 '08 #1
0 1068

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: paul | last post by:
Hi everyone, I'm having problems displaying a date in the correct format and I was wondering if anyone knew how to help. I'm using pear to extract a date from our back end database (the date is...
0
by: George | last post by:
I have two tables and want to find the Maximum date for a given GIN. I have been able to produce the result in Sybase but I am having problems in Oracle. Example of my query in Sybase. create...
8
by: Michael C | last post by:
Hi all, I'm still having problems with VS.NET 2003 running on my XP machine. I finally decided I might as well uninstall completely and reinstall from scratch. But lo and behold it won't let...
4
by: Charles | last post by:
I am still having problems with sessions crossing over from other sessions. What I mean by this is that Mary may get just some or all of Renae’s information. I think that what is going on with...
11
by: Rick Mogstad | last post by:
I know this is probably not the group for this, but i know that these groups are fairly active, and that the people are usually willing to help. Is anyone else experiencing this? The news...
7
by: Ron | last post by:
Hi All, It's taking a long, LONG time for me to see a post from here (and other NGs too, for that matter--which is why I think it may be me...). Sometimes it takes 2-3 minutes after clicking...
2
by: l46kok | last post by:
Hello. This is the first time I'm encountering vectors and I'm having problems. I want to create a vector filled with objects, but as soon as I try to invoke a function within the object, ...
1
by: tshad | last post by:
Some of my regular expressions don't seem to work correctly in IE7. I am on asp.net 1.1. I have a site that has been up for a while and I started having problems on machines with IE7. IE5 and...
4
by: chris | last post by:
Hello all, I am having problems getting Apache 2.2.4 to read the php_mysqli.dll file some my C:\php\ext\ directory. The following is the error that Apache displays in the error log: PHP...
6
by: fpcreator2000 | last post by:
Hello everyone. I'm having problems with a page I've created that is used to insert data into a database. It uploads two files into two distinct folder, and it takes the filenames and inserts...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.