Bug 34754 - Queries to ODBC sources throw exception
Summary: Queries to ODBC sources throw exception
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Data ()
Version: 4.0.0
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2015-10-11 14:36 UTC by Ryan
Modified: 2015-10-13 13:21 UTC (History)
1 user (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Ryan 2015-10-11 14:36:36 UTC
The most basic queries to ODBC sources work ok (ie. select * from class), but any queries containing any named columns fail (ie. select id from class)

       using (OdbcConnection oConnection = new OdbcConnection(connectionString))
           using (OdbcCommand cmd = new OdbcCommand(sqlStmt, oConnection))
               OdbcDataReader dr = cmd.ExecuteReader();


       DbConnection dbcon = new OdbcConnection(connectionString);

       DbCommand cmnd = System.Data.Odbc.OdbcFactory.Instance.CreateCommand();
       cmnd.Connection = dbcon;
       cmnd.CommandText = sqlStmt;
       DbDataAdapter da = System.Data.Odbc.OdbcFactory.Instance.CreateDataAdapter ();
       da.SelectCommand = cmnd;

       da.Fill (dt);

I suspect this is related to issue 30694 where column names are not returned correctly (corrupted column names).  Unfortunately this means that ODBC sources cannot be used at all in mono and System.Data.Odbc.OdbcCommand.ExecuteReader(...) is incorrectly listed as "Complete" in the class status page.
Comment 1 Ryan 2015-10-13 13:21:49 UTC
Possibly related to ODBC driver?  While the names are corrupt in all drivers I have tried, this bug seems to be driver dependent.