ODBC "Umlaut" problem -
09-04-2004
, 03:53 PM
My problem is that I want to fill a dataset from a mysql database, but
instead of the german special characters (Umlaut) I get some garbage.
I'm using C# and my code is
strSelectKommando = "SELECT * FROM Empfaenger WHERE
id=" + id;
// id is the primary key, so there will be only 1
element in the dataset
strConnection = "STMT=;OPTION=3;DSN=xxx;UID=xxx;PASSWORD=xxx;DESC= MySQL
ODBC 3.51 Driver DSN;DATABASE=xxx;SERVER=localhost;PORT=3306";
odBcVerbindung = new OdbcConnection(strConnection);
odBcKommando = new OdbcCommand(strSelectKommando, odBcVerbindung);
daAdapter = new OdbcDataAdapter(odBcKommando);
dsNamenSatz = new DataSet();
try
{
odBcVerbindung.Open();
daAdapter.Fill(dsNamenSatz, "Empf");
}
catch (OdbcException ex)
{ ... }
odBcVerbindung.Close();
foreach (DataRow datReihe in dsNamenSatz.Tables["Empf"].Rows)
{
try
{
someStringVariable = datReihe["Name"].ToString();
}
catch
{
someStringVariable = "";
}
}
If the entry for Name contains an Umlaut, the variable
someStringVariable will contain some garbage characters instead where
the Umlaut should appear.
Any help is appreciated! Thanks a lot! |