[Mono-list] Problems with ODBC Connection

beniniva@csr.unibo.it beniniva@csr.unibo.it
Thu, 11 Mar 2004 08:52:11 +0100


I've an ODBC connection test named TestODBC.cs 
(connecting to MySQL database with a connection string) that works correctly 
on Windows XP using Visual Studio.Net 2003, but not on Mono.

I compiled and ran TestODBC.cs, but threre are errors.

On Windows:

->mcs TestODBC.cs -r System.Data.dll

 Compilation succeeded

->mono TestODBC.exe

 Unhandled Exception: System.Data.Odbc.OdbcException: Error in SQLAllocHandle
 in <0x000bb> System.Data.Odbc.OdbcConnection:.ctor ()
 in <0x0000a> System.Data.Odbc.OdbcConnection:.ctor (string)
 in <0x0004d> (wrapper remoting-invoke-with-check)
System.Data.Odbc.OdbcConnection:.ctor (string)
 in <0x00066> TestODBC.Test:Main ()


On Linux (via UnixODBC)

# mcs TestODBC.cs  -r System.Data.dll
 Compilation succeeded

# mono TestODBC.exe
 Unhandled Exception: System.DllNotFoundException: odbc32
in <0x0005c> (wrapper managed-to-native)
System.Data.Odbc.libodbc:SQLAllocHandle
 (System.Data.Odbc.OdbcHandleType,intptr,intptr&)
in <0x00073> System.Data.Odbc.OdbcConnection:.ctor ()
in <0x0000a> System.Data.Odbc.OdbcConnection:.ctor (string)
in <0x00056> (wrapper remoting-invoke-with-check)
System.Data.Odbc.OdbcConnectio
n:.ctor (string)
in <0x00069> TestODBC.Test:Main ()

######
TestODBC.cs
######
using System;
using System.Data;
using System.Data.Odbc;

namespace TestODBC 
{        class Test 
        {
                public static void Main()
                { 
                        OdbcDataReader dbReader = null;
                        OdbcConnection conn = null;
                       
                        conn = new OdbcConnection("DRIVER={MySQL ODBC 3.51
Driver};"+"SERVER=localhost;"+"DATABASE=db1;"+"UID=utente;"+"PASSWORD=utentepwd;");
                        conn.Open();
.
.
.
.

######
Where is the error?
Could anybody help me?

Thanks,
Vale.