[Mono-list] compiling myodbc app on linux
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
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.
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
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?
Did you create an ODBC DSN for you to connect to a MySQL database?
From: email@example.com [mailto:firstname.lastname@example.org]On
Behalf Of mind
Sent: Wednesday, January 01, 2003 7:12 AM
Subject: [Mono-list] compiling myodbc app on linux
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,
what i'm doing wrong?
btw Happy New Year 2 All Developers! :D
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.Data.Odbc; // should be using Microsoft.Data.Odbc ??
static void Main()
OdbcConnection connection = new OdbcConnection("DSN=MySQL");
// Write info
Console.WriteLine("Database:\t" + connection.Database);
Console.WriteLine("Server ver.:\t" +
// Close Connection
Mono-list maillist - Monoemail@example.com