LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Mono, System.Data.Common.DbConnection (https://www.linuxquestions.org/questions/programming-9/mono-system-data-common-dbconnection-544383/)

TotalLinuxNoob 04-08-2007 05:55 PM

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

hgb 04-09-2007 11:48 AM

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.

TotalLinuxNoob 04-09-2007 01:43 PM

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]


hgb 04-09-2007 02:18 PM

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.

TotalLinuxNoob 04-09-2007 04:48 PM

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


All times are GMT -5. The time now is 06:03 PM.