[Mono-list] ByteFX.Data broken in Beta1?

Artur Brodowski bzdurqa@wp.pl
Mon, 24 May 2004 23:19:36 +0200


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:

Unhandled Exception: System.NullReferenceException: Object reference not
set to an instance of an object
in <0x0025a> ByteFX.Data.MySqlClient.MySqlStream:get_DataAvailable ()
in <0x00051> ByteFX.Data.Common.MultiHostStream:Read (byte[],int,int)
in <0x0003d> ByteFX.Data.MySqlClient.MySqlStream:ReadInt24 ()
in <0x00050> (wrapper remoting-invoke-with-check)
ByteFX.Data.MySqlClient.MySqlStream:ReadInt24 ()
in <0x0005b> ByteFX.Data.MySqlClient.Driver:ReadRawPacket ()
in <0x0004e> ByteFX.Data.MySqlClient.Driver:ReadPacket ()
in <0x00094> ByteFX.Data.MySqlClient.Driver:Open
(ByteFX.Data.MySqlClient.MySqlConnectionString)
in <0x0003c> ByteFX.Data.MySqlClient.MySqlInternalConnection:Open ()
in <0x000ef> ByteFX.Data.MySqlClient.MySqlPool:CreateNewPooledConnection
()
in <0x00212> ByteFX.Data.MySqlClient.MySqlPool:GetPooledConnection ()
in <0x00052> ByteFX.Data.MySqlClient.MySqlPool:GetConnection ()
in <0x00117> ByteFX.Data.MySqlClient.MySqlPoolManager:GetConnection
(ByteFX.Data.MySqlClient.MySqlConnectionString)
in <0x00077> ByteFX.Data.MySqlClient.MySqlConnection:Open ()
in <0x00064> Foo:.ctor ()
in <0x0001b> Foo:Main (string[])

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.