I've set up system DSNs, which I can use from other ODBC apps (e.g. iQueryODBC), but in mono, I get "Data source name not found and n" (sic).
I am using "DSN=myodbc" for the connection string, via the connection string builder.
OSX 10.4
Latest Mono packages - 2.4.2.3.
Anyone ever got ODBC working on Mono/ OSX?
(Oh - for what it is worth - and I am fairly certain it is not relevant - the DSN is for MySql 5 driver.)
Full code:
public static void Main (string[] args)
{
OdbcConnectionStringBuilder csb = new OdbcConnectionStringBuilder();
csb.Dsn = args[0];
DataSet d = GetDataSet(csb.ConnectionString , "SELECT * FROM tbl");
Console.WriteLine (d.Tables.Count);
}
public static DataSet GetDataSet(string connectionString, string queryString)
{
Console.WriteLine("GetDataSetFromAdapter(" + connectionString + ")");
DataSet dataSet = new DataSet();
using (OdbcConnection connection = new OdbcConnection(connectionString))
{
OdbcDataAdapter adapter = new OdbcDataAdapter(queryString, connection);
// Open the connection and fill the DataSet.
try
{
connection.Open();
adapter.Fill(dataSet);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
return dataSet;
}