[Mono-dev] Problem with national character set on ODBC connection

Torello Querci tquerci at gmail.com
Wed Feb 13 12:01:07 EST 2008

Hi to all .....

I try to make an ODBC connection on windows environment.
Using normal ascii character that code work fine, but if there is some
national character, the result is wrong.
The result is wrong only if I make a bundle, not if I use mono
<program_name.exe> or if I use .NET.
I tried both the 1.2.6 and the 1.9 preview and the result is the same.

Is there a bug or I wrong something when generate the bundle

To generate the bundle I simply use this command:
mkbundle2 --deps -o odbx2xml.exe program.exe

Best Regards, Torello.

The testing database is an access file with one table named "users"
with 3 column: name, surname, description with only one row ....

Here you can find the code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Data.Odbc;

namespace test_odbc
    class testOdbc : IDisposable
        private System.Data.Odbc.OdbcConnection connection = null;

        public testOdbc(string connectionString)
            connection=new OdbcConnection(connectionString);
            catch (Exception ex)
                connection = null;
                System.Console.Out.WriteLine("Exception opening the
database connection: " + ex.Message);


        public System.Data.Common.DbDataReader getRawData(string sqlQuery)
            System.Data.Odbc.OdbcCommand command=connection.CreateCommand();
            command.CommandText = sqlQuery;
            command.CommandType = System.Data.CommandType.Text;
            OdbcDataReader reader = command.ExecuteReader();

            return reader;

        public System.Collections.ArrayList
getListOfFields(System.Data.Common.DbDataReader reader)
            ArrayList fieldNameList = new ArrayList();
            System.Data.DataTable dataTable = reader.GetSchemaTable();
            foreach (System.Data.DataRow row in dataTable.Rows)
                if (!fieldNameList.Contains(row["Co6lumnName"].ToString())) {

            return fieldNameList;

        public void Dispose()
            if (connection != null)


        static void Main(string[] args)
            testOdbc odbc = new testOdbc("Dsn=test");
            System.Data.Common.DbDataReader reader =
odbc.getRawData("select * from users");
            while (reader.Read())
                for (int i = 0; i < reader.FieldCount; i++)
                    object obj = reader.GetValue(i);
                    System.Console.Out.WriteLine("column " + i + "
data: " + reader.GetValue(i).ToString());

More information about the Mono-devel-list mailing list