[Mono-list] ByteFX.Data broken in Beta1?
Scott Lowe
scott@budomail.com
Tue, 25 May 2004 10:25:07 +0100
Hello Arthur,
Make sure that you have the latest and greatest release of the
ByteFX.Data
data provider from http://sourceforge.net/projects/mysqlnet/
If I recall correctly, the version that ships with Mono is a much older
version, and has
been updated in CVS for the next release of Mono.
I used ByteFX.Data version 0.76 and Mono Beta1 to compile your console
application and it worked fine, although I had to change the line:
Console.WriteLine((string) dbcmd.ExecuteScalar());
to
Console.WriteLine(Convert.ToString(dbcmd.ExecuteScalar()));
... because I was getting and invalid cast exception.
Have fun,
Scott
> From: Artur Brodowski <bzdurqa@wp.pl>
> Date: 24 May 2004 22:19:36 BST
> To: mono-list@lists.ximian.com
> Subject: [Mono-list] ByteFX.Data broken in Beta1?
>
>
> Hello,
> I wanted to write simple MySQL app, but the code from
> http://www.go-mono.com/mysql.html
> doesn't work with Mono/mcs beta1:
>
> using System;
> using System.Data;
> using ByteFX.Data.MySqlClient;
>
> public class Foo
> {
> public static int Main(string [] args)
> {
> new Foo();
> return 0;
> }
>
> Foo()
> {
> string connString =
> "server=localhost;" +
> "database=database;" +
> "User ID=user;" +
> "Password=pass";
> IDbConnection dbh = new MySqlConnection(connString);
> dbh.Open ();
>
> if(dbh != null) {
> IDbCommand dbcmd = dbh.CreateCommand();
>
> string query = "SELECT NOW()";
> dbcmd.CommandText = query;
> Console.WriteLine((string) dbcmd.ExecuteScalar());
>
> dbcmd.Dispose();
> dbcmd = null;
> dbh.Close();
> dbh = null;
> }
> }
> }
>
> Afre compiling and running it returns:
> I found out that MySqlConnection method returns null value, which is
> passed to dbh.Open(), and that of course raises exception.
> But why it behaves this way? I can login to mysql from command line
> just fine, looks like this is driver issue...
>
> artb.