[Mono-list] ODBC/UnixODBC

Petit Eric surfzoid at gmail.com
Sat Dec 20 07:16:56 EST 2008


My bad, the mdb driver had an incorect setting in UNIXODBC conf, so
now it is okay, except i can only use DSN as connection string

2008/12/20 Petit Eric <surfzoid at gmail.com>:
> Hi
> I'm trying a sample to connect to a mdb Access database (read only)
> with mdbtool/libodbcmdb.
> I see a first error in Mono ODBC managment, in the connection string,
> the driver is in bracket like that Driver={Microsoft Access Driver
> (*.mdb)} , but this give an Unhandled Exception:
> System.Data.Odbc.OdbcException with Database not found or Driver not
> specified, without bracket it is okay but don't folow the same way as
> windows/.NET.
>
> The libodbc.so from devel package seem requiere, why a devel pkg for a
> runtime, is there a way to use the libodbc.so.1.0 from normal rpm ?
>
> Now let's see my sample :
> using System;
> using System.Data;
> using System.Data.Odbc;
> using System.Windows.Forms;
>
> namespace TestMdbCle
> {
>        class MainClass
>        {
>                public static void Main(string[] args)
>                {
>                        Frm.Shown += new EventHandler(Form1_Shown);
>                        Frm.ShowDialog();
>                }
>
>        static string CntStr = "Driver=Microsoft Access Driver
> (*.mdb);Dbq=/home/eric/tmp/Gestion_bornesrempli.mdb;Uid=Admin;Pwd=bfadi.;";
>        //static string CntStr = "DSN=test;Uid=Admin;Pwd=bfadi.;";
>        static Form Frm = new Form();
>        static void BuildDtObjs()
>        {
>                DataGridView DtG = new DataGridView();
>                OdbcConnection Cnt = new OdbcConnection(CntStr);
>                OdbcDataAdapter DtAdpt = new OdbcDataAdapter("SELECT * FROM Affaires", Cnt);
>                DataSet Ds = new DataSet();
>                DtAdpt.Fill(Ds);
>                DtG.DataSource = Ds;
>                DtG.DataMember = Ds.Tables[0].TableName;
>                Frm.Controls.Add(DtG);
>
>        }
>
>
>
>        private static void Form1_Shown(object sender, EventArgs e)
>
>        {
>                        BuildDtObjs();
>                }
>
>        }
> }
>
> When trying to Fill data in the Dataset i get :
>
>
> Unhandled Exception: System.Data.Odbc.OdbcException: ERROR [IM004]
> [unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV
> failed
>  at System.Data.Odbc.OdbcConnection.Open () [0x00263] in
> /root/tmp/MonoUpdate/mcs/class/System.Data/System.Data.Odbc/OdbcConnection.cs:397
>
> I'm not able to go more far, any idea ?
> --
>
> Cordially.
>
> Small Eric Quotations of the days:
> ---------------------------------------------------------------------------
> If one day one reproaches you that your work is not a work of
> professional, say you that:
> Amateurs built the arch of Noah, and professionals the Titanic.
> ---------------------------------------------------------------------------
>
> Few people are done for independence, it is the privilege of the powerful ones.
> ---------------------------------------------------------------------------
>
> No key was wounded during the drafting of this message.
>



-- 

Cordially.

Small Eric Quotations of the days:
---------------------------------------------------------------------------
If one day one reproaches you that your work is not a work of
professional, say you that:
Amateurs built the arch of Noah, and professionals the Titanic.
---------------------------------------------------------------------------

Few people are done for independence, it is the privilege of the powerful ones.
---------------------------------------------------------------------------

No key was wounded during the drafting of this message.


More information about the Mono-list mailing list