[Mono-list] ByteFX.Data.MySqlClient : no instance, a null value instead

David Marsal david.marsal@lmt.ens-cachan.fr
Fri, 30 Jan 2004 13:52:18 +0100


Running mono from cvs, I wrote the following test.cs
(from the go-mono site) :

=======================================

 using System;
 using System.Data;
 using ByteFX.Data.MySqlClient;
 
 public class Test
 {
    public static void Main(string[] args)
    {
       string connectionString =
          "Server=localhost;" +
          "Database=monotest;" +
          "User ID=monotest;" +
          "Password=monotest;";
       IDbConnection dbcon;
       dbcon = new MySqlConnection(connectionString);
       dbcon.Open();
       IDbCommand dbcmd = dbcon.CreateCommand();
       // requires a table to be created named employee
       // with columns firstname and lastname
       // such as,
       //        CREATE TABLE employee (
       //           firstname varchar(32),
       //           lastname varchar(32));
       string sql =
           "SELECT person, email" +
           "FROM test";
       dbcmd.CommandText = sql;
       IDataReader reader = dbcmd.ExecuteReader();
       while(reader.Read()) {
            string FirstName = (string) reader["firstname"];
            string LastName = (string) reader["lastname"];
            Console.WriteLine("Name: " +
                  FirstName + " " + LastName);
       }
       // clean up
       reader.Close();
       reader = null;
       dbcmd.Dispose();
       dbcmd = null;
       dbcon.Close();
       dbcon = null;
    }
 }

My aim is to use a similar script with xsp
but one problem at a time...

=======================================

compilation is all right :

mcs test.cs -r System.Data.dll  -r ByteFX.Data.dll
Compilation succeeded

=======================================

But running failed :

mono test.exe

Unhandled Exception: System.NullReferenceException: A null value was 
found where an object instance was required
in <0x00061> ByteFX.Data.MySqlClient.MySqlStream:get_DataAvailable ()
in <0x00058> ByteFX.Data.Common.MultiHostStream:Read (byte[],int,int)
in <0x00040> ByteFX.Data.MySqlClient.MySqlStream:ReadInt24 ()
in <0x00050> (wrapper remoting-invoke-with-check) 
ByteFX.Data.MySqlClient.MySqlStream:ReadInt24 ()
in <0x00062> ByteFX.Data.MySqlClient.Driver:ReadRawPacket ()
in <0x0005c> ByteFX.Data.MySqlClient.Driver:ReadPacket ()
in <0x00094> ByteFX.Data.MySqlClient.Driver:Open 
(ByteFX.Data.MySqlClient.MySqlConnectionString)
in <0x0003f> ByteFX.Data.MySqlClient.MySqlInternalConnection:Open ()
in <0x000fa> ByteFX.Data.MySqlClient.MySqlPool:CreateNewPooledConnection ()
in <0x00235> ByteFX.Data.MySqlClient.MySqlPool:GetPooledConnection ()
in <0x0005d> ByteFX.Data.MySqlClient.MySqlPool:GetConnection ()
in <0x0011b> ByteFX.Data.MySqlClient.MySqlPoolManager:GetConnection 
(ByteFX.Data.MySqlClient.MySqlConnectionString)
in <0x00077> ByteFX.Data.MySqlClient.MySqlConnection:Open ()
in <0x00071> .Test:Main (string[])

which is not so clear for me...
I just believe to understand that the instance ByteFX.Data.MySqlClient 
instance doesn't exists
but why ?

=======================================

Then I use sqlsharp :

SQL# \Provider MySqlNET
The default Provider is LOADEXTPROVIDER
          Assembly: ByteFX.Data
  Connection Class: ByteFX.Data.MySQLClient.MySQLConnection

SQL# \ConnectionString Server=localhost;Database=monotest;User 
ID=monotest;Password=monotest;

SQL# \Open
Attempt to open connection...
Loading external provider...
Error: unable to load the assembly of the provider: ByteFX.Data : 
Argument cannot be null
Parameter name: type

same problem ?

=======================================

Then I use mysql :

mysql -u monotest -p

Enter password: ( monotest)

mysql> use monotest;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

SELECT * FROM test;
+--------+---------+
| person | email   |
+--------+---------+
| moi    | moi@moi |
+--------+---------+
1 row in set (0.00 sec)

Ok !
=======================================

I just check that
/usr/local/mono/lib/ByteFX.Data.dll exists and is up to date

I succeeded in compiling GnomeDbClient.cs and client.cs
but failed to access my databases

Many many thanks for your help.