Bug 39787 - Error while connecting database using ODBC after update
Summary: Error while connecting database using ODBC after update
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Data (show other bugs)
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-03-19 12:35 UTC by Abhinav Aggarwal
Modified: 2018-02-22 22:24 UTC (History)
6 users (show)

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


Attachments
Snapshot showing successful connection through odbc (217.50 KB, image/png)
2016-03-19 12:55 UTC, Abhinav Aggarwal
Details


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:
Status:
RESOLVED FIXED

Description Abhinav Aggarwal 2016-03-19 12:35:36 UTC
Hi, 

I have updated monodevelop on Ubuntu 14.04 from version 4.2 to 5.10. 

I was able to connect the oracle databases using ODBC successfully earlier in version 4.2

After update to 5.10, my codes stopped connecting to the database and i am getting the error stating 
"ERROR [IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified"

I have checked in the system, my machine is properly configured to connect the database using ODBC. 

I am also able to connect the database using isql through odbc seamlessly. 

I think that there is something missing in the update, that is limiting my code to connect to the database. 

An early response will be highly appreciable. 

Regards. 

Abhinav Aggarwal
Comment 1 Abhinav Aggarwal 2016-03-19 12:51:26 UTC
I am attaching the basic code that i created for the testing purposes. 

		public void TestODBCConn()
		{
			try
			{
				string connString="Driver={OracleODBC-11.2};DSN=shilpiCapMkt;Uid=abhi123;Pwd=abhi1234;Pooling=false;";
				System.Data.Odbc.OdbcConnection Conn = new OdbcConnection(connString);
				Conn.Open();
				string sql="Select count(*) from partymst";
				System.Data.Odbc.OdbcDataAdapter da = new OdbcDataAdapter(sql,Conn);
				System.Data.DataSet ds = new DataSet();
				da.Fill(ds, "Partymst");
				Console.WriteLine(ds.Tables[0].Rows[0][0].ToString());
				Conn.Close();
			}
			catch(Exception E)
			{
				Console.WriteLine (E.Message+ " at: "  +System.DateTime.Now.ToString("yyyyMMddHHmmss"));
			}
		}


the system is throwing error at Conn.Open();
Comment 2 Abhinav Aggarwal 2016-03-19 12:55:07 UTC
Created attachment 15464 [details]
Snapshot showing successful connection through odbc

I am also attaching a snapshot showing that i am able to connect to the database using isql, and odbc is properly configured in the machine.
Comment 3 Andi McClure 2016-04-05 20:39:20 UTC
Looking:

My guess is that at the same time we switched from Mono BCL to MS referencesource BCL (Mono 4.2) this broke. Probably when Abhinav switched from monodevelop 4.2 to 5.10 Ubuntu upgraded Mono at the same time.

Looking at the referencesource code it appears to mostly wrap Odbc32.dll in both the referencesource version

https://github.com/mono/mono/tree/8ac788afb3b9f0d529d11291f99b270ce626d891/mcs/class/System.Data/System.Data.Odbc

and the old version

https://github.com/mono/mono/blob/8ac788afb3b9f0d529d11291f99b270ce626d891/mcs/class/System.Data/System.Data.Odbc/libodbc.cs

Abhinav, what mono version are you running ( ie what do you get if you run mono --version )? Do you know if you were running the same version of Mono when this was working?

Would it be practical for you to downgrade to the previous Mono and see if it starts working again?

We do not at present have a setup here for testing ODBC. I'd wonder, if you simply included the old System.Data.Odbc classes into your application instead of including from the System.Data DLL https://github.com/mono/mono/tree/8ac788afb3b9f0d529d11291f99b270ce626d891/mcs/class/System.Data/System.Data.Odbc if you could get the old, working ODBC behavior even post-4.2.
Comment 4 Abhinav Aggarwal 2016-04-12 02:28:54 UTC
Hello Andi 

After upgrade I had following mono version. 

Mono JIT compiler version 4.2.3 (Stable 4.2.3.4/832de4b Wed Mar 16 13:19:08 UTC 2016)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	LLVM:          supported, not enabled.
	GC:            sgen

I tried downgrading the system and its working fine as it was working earlier. 

I am working with the downgraded version only. 

Hope the issue get resolved in the next update. 

Thanks and Regards. 

Abhinav
Comment 5 Michael Lechthaler 2016-05-29 21:39:05 UTC
Hi, I'm having the exact same problem. Any news about when a fix will be available or which older version to use?

Best regards
Michael
Comment 6 Marek Safar 2018-02-22 22:24:46 UTC
Mono 5.10 has significantly improved System.Data implementation which should resolve this issue. If you can still reproduce it please reopen the issue.