LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-08-2007, 05:55 PM   #1
TotalLinuxNoob
Member
 
Registered: Apr 2005
Distribution: Ubuntu
Posts: 109

Rep: Reputation: 15
Mono, System.Data.Common.DbConnection


<rant>
I try really hard to give mono a chance b/c I want it to work but it's constantly letting me down...
Everything seems to be coming on nicely (like monodevelop) but the little things still stop you from being as productive as you would be on the M$ platform.. I haven't found out yet where I can find which version of Mono it is using to compile my app and the code completion is too limited - displaying method parameters would be nice atleast.
xsp2 doesn't support the src tag (this took me ages) so I'm back to xsp. Then there is the lack of Atlas support...
</rant>

I've been spending ages installing/uninstalling mono, setting the GAC and what not to try and get the mySql Connector working but constantly end up with a missing Dbconnection. Thinking it was down to xsp.
Finally I have just written a piece of sample code in MonoDev and it results in the same error even though all the references are set:

Code:
using System;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using MySql.Data.MySqlClient;

namespace dataAttempt
{	
	public class DataRetriever
	{		
		public DataRetriever()
		{
			MySqlConnection conn = new MySqlConnection();
			/*conn.Database = "tria";
			conn.Site = "127.0.0.1:3306";
			conn.Open();*/
			
		}
		
		public static void Main(string[] args)
		{
			new DataRetriever();
			Console.Write("done");
		}
	}
}
error:
Quote:
[Task:File=, Line=0, Column=0, Type=Error, Description=Could not load type 'System.Data.Common.DbConnection' from assembly 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.(Exception: System.TypeLoadException)
Then there seems to be the lack of community.. gotmono.com seems dead and there's no talk in the IRC channels... I'm almost considering switching my .Net work to Windows hosting and code apps in Java...

Thanks all
 
Old 04-09-2007, 11:48 AM   #2
hgb
Member
 
Registered: Jun 2004
Distribution: Mandrake 10, SUSE 10.x, DEbian
Posts: 125

Rep: Reputation: 15
I have been able to connect with oracle 10 xe, dont know about your problem, tought, you can try at irc.freenode.net in ##mono, ##csharp or irc.gnome.org in #mono and maybe in #monodevelop but it seem more like a working in the src of monodevelop...


From my experience at the first time, I have some problem even connecting to the DB of oracle, tought it was because there wasnt any oracle instance running...


from http://www.mono-project.com/Use -> http://www.mono-project.com/Database_Access -> http://www.mono-project.com/MySQL ... is the one that are you using like a reference???

I dont have here MySQL.
 
Old 04-09-2007, 01:43 PM   #3
TotalLinuxNoob
Member
 
Registered: Apr 2005
Distribution: Ubuntu
Posts: 109

Original Poster
Rep: Reputation: 15
Finally got something working...(After setting the application to 2.0 in monodev it found the missing db class) after another reinstall of mono. System.Transactions could not be found even though it was in it's designated directory. So I tried adding it with gacutil -i System.Transactions.dll. with root permissions. It couldn't find it. Unsurprising b/c it removed it. This explains some problems I've had with other libraries as well now.

(It still is frustrating b/c it should have been found).

After a reinstall of mono it was back but despite adding the right references the problem remained. After copying it to the application directory it works. I'm now fighting the connection string which I've copied and modified from http://www.mono-project.com/MySQL . It says it cannot connect to the (sepcified hosts) database even though I can telnet to mySql and login with the query browser.

Once I can connect I'll look into being able to have datasets returned instead of using IDataReader, which they use in the example.

Thank you for your help.

oh, and my connection code:

Code:
string strCon =  "Server=127.0.0.1;" + "Database=tria;" + "User ID=xxxx;"  + "Pooling=false";
			IDbConnection conn = new MySqlConnection(strCon);
			IDbCommand cmd = conn.CreateCommand();
conn.Open();
(Indeed, no password is used)
(Pooling gives us thread errors)

throws error:
Code:
Unhandled Exception: MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts. ---> System.Exception: Exception of type System.Exception was thrown.
  at MySql.Data.MySqlClient.NativeDriver.Open () [0x00000] --- End of inner exception stack trace ---

  at MySql.Data.MySqlClient.NativeDriver.Open () [0x00000] 
  at MySql.Data.MySqlClient.Driver.Create (MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings) [0x00000] 
  at MySql.Data.MySqlClient.MySqlConnection.Open () [0x00000]

Last edited by TotalLinuxNoob; 04-09-2007 at 02:23 PM.
 
Old 04-09-2007, 02:18 PM   #4
hgb
Member
 
Registered: Jun 2004
Distribution: Mandrake 10, SUSE 10.x, DEbian
Posts: 125

Rep: Reputation: 15
A yea, it remind me the same problem, tought instead of copy the dll (of oracle DLL), I have added the path to my

Code:
/etc/ld.so.conf
Code:
tyoc@x:/$ sudo cat /etc/ld.so.conf
Password:
/usr/lib/oracle/xe/app/oracle/product/10.2.0/server/lib
/usr/local/lib
And...
Code:
tyoc@x:/$ sudo ldconf
tyoc@x:/$ ldconf -p |grep oracle
For see if the .so is there .


By the way, I link my post back.... using oracle xe 10g with c# in monodevelop

If it serve for something "extra"... tought I think no... lol.
 
Old 04-09-2007, 04:48 PM   #5
TotalLinuxNoob
Member
 
Registered: Apr 2005
Distribution: Ubuntu
Posts: 109

Original Poster
Rep: Reputation: 15
Code:
string strCon =  "Server=localhost;Port=3306;connect timeout=10;Password=;" + "Database=tria;" + "User ID=root;"  + "Pooling=false";
			IDbConnection conn = new MySqlConnection(strCon);
			conn.Open();
Does work
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problems upgrading dapper, common system utilities missing SerfurJ Ubuntu 2 01-28-2007 06:09 PM
Help Mono Installed But Mono Develop Won't Load TheGreatGonzo Slackware 8 05-18-2006 06:42 AM
Common Data Storage Woodsman Slackware 1 10-30-2005 10:00 PM
Why can't a common hardware driver format/system be developed? oudent Linux - General 6 02-01-2004 11:08 PM
common file system? felixnine Linux - Software 1 12-20-2001 10:31 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration