[Mono-list] compiling myodbc app on linux

Daniel Morgan danmorg@sc.rr.com
Thu, 2 Jan 2003 07:44:07 -0500


This question probably can be best answered by Brian Ritchie or Venu.
However, I will try.

On UNIX and Linux, they do not have built-in support for ODBC like Microsoft
Windows does.  If you need ODBC you will have to install ODBC support.
There is unixODBC and iODBC.  Both are open source and commerically
supported.

unixODBC from http://www.unixodbc.org/
iODBC from http://www.iodbc.org/

The ODBC provider found in Mono at mcs/class/System.Data/System.Data.Odbc
has been tested
with unixODBC.  It has not been tested with iODBC.  I would like to hear if
someone got it to work with iODBC.

Please read this article about connecting to MySQL on the .NET Framework.
It does not
mention Mono, but it is a good article.
http://www.mysql.com/articles/dotnet/

Your using statement is correct, it should be System.Data.Odbc.

The ODBC add-on suppport as Microsoft.Data.Odbc came out after .NET 1.0
Framework was released.  The .NET Framework 1.1 includes ODBC support as
System.Data.Odbc and is now part of the System.Data.dll assembly.  This is
why Mono decided to use System.Data.Odbc for the ODBC support.

As for the compile error saying it could not find OdbcConnection, did you
reference the System.Data.dll assembly?

mcs MySqlSimple.cs -r System.Data.dll
or
mcs MySqlSimple.cs /r:System.Data.dll

You can always include the path to your assemblies when compiling:
mcs MySqlSimple.cs -lib:$HOME/mono/install/lib -r System.Data.dll

Is the path to your mono assemblies in your LD_LIBRARY_PATH?
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/mono/install/lib

Did you create an ODBC DSN for you to connect to a MySQL database?

-----Original Message-----
From: mono-list-admin@ximian.com [mailto:mono-list-admin@ximian.com]On
Behalf Of mind
Sent: Wednesday, January 01, 2003 7:12 AM
To: mono-list@ximian.com
Subject: [Mono-list] compiling myodbc app on linux


hi there,

what about compiling ODBC application on linux (MyODBC 2.x, or 3.x)?
can it be done?

after successfull instalation of mono ('hello world!' compiles ok) and
libmyodbc (2.50.39-3) on Debian i cannot connect to odbc provider,
why?
what i'm doing wrong?

greetz,
btw Happy New Year 2 All Developers! :D

/pd

---

error message is:

MySqlSimple.cs(17) error CS0246: Cannot find type `OdbcConnection'
Compilation failed: 1 error(s), 0 warnings

ps. i set up $MONO_PATH to /usr/lib/odbc/ where libmyodbc.so can be
found. maybe i should use 3.x version instead of 2.x one?

---

simple source code looks like this:

---

using System;
using System.Data.Odbc; // should be using Microsoft.Data.Odbc ??

class My
{
        static void Main()
        {
                // Connect
                OdbcConnection connection = new OdbcConnection("DSN=MySQL");
                connection.Open();

                // Write info
                Console.WriteLine("Database:\t"    + connection.Database);
                Console.WriteLine("Server ver.:\t" +
connection.ServerVersion);

                // Close Connection
                connection.Close();
        }
}




_______________________________________________
Mono-list maillist  -  Mono-list@ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list