[Mono-list] FW: MySql Connector

Daniel Morgan monodanmorg at yahoo.com
Fri Oct 20 09:38:59 EDT 2006


Before you set your data adapter and command to null,
try using Dispose().  I don't have the docs in front
of me right now to see if data adapter has a
Dispose(), but I do know command does.

--- Damien Churchill <damien.churchill at ukplc.net>
wrote:

> Yeah I would have thought that as well, but that's
> on a single
> statement. I wrote a simple console program to test
> it.
> 
> using System;
> using System.Data;
> using System.Collections.Generic;
> using System.Text;
> using MySql.Data.MySqlClient;
> namespace mysqltest
> {
>     class Program
>     {
>         static void Main(string[] args)
>         {
>             string connectionString =
>                 "Server=***.***.***.***;" +
>                 "Database=********;" +
>                 "User ID=********;" +
>                 "Password=********;" +
>                 "Allow Zero Datetime=true";
> 
>             MySqlConnection dbConn = new
> MySqlConnection(connectionString);
>             dbConn.Open();
> 
>             MySqlDataAdapter da = new
> MySqlDataAdapter();
>             MySqlCommand dbcmd =
> dbConn.CreateCommand();
>             dbcmd.CommandText = "CALL
> spUserPrivileges(1);";
>             DataSet ds = new DataSet();
> 
>             da.SelectCommand = dbcmd;
>             da.Fill(ds);
> 
>             dbcmd = null;
>             da = null;
> 
>            
> Console.WriteLine(ds.Tables[0].Rows.Count);
>             Console.Read();
>         }
>     }
> }
> 
> That's all it does. It works fine with other
> selects, and other stored
> procedures, just not that one.
> 
> 
> -----Original Message-----
> From: mono-list-bounces at lists.ximian.com
> [mailto:mono-list-bounces at lists.ximian.com] On
> Behalf Of Robert Jordan
> Sent: 20 October 2006 11:28
> To: Mono-list at lists.ximian.com
> Subject: Re: [Mono-list] MySql Connector
> 
> Damien Churchill wrote:
> > I was wondering has anyone else has experienced
> this:
> >  
> > Unhandled Exception:
> MySql.Data.MySqlClient.MySqlException: There is
> > already an open DataReader associated with this
> Connection which must
> be
> > closed first.
> >   at
> MySql.Data.MySqlClient.MySqlCommand.CheckState ()
> [0x00000] 
> >   at
> MySql.Data.MySqlClient.MySqlCommand.ExecuteReader
> (CommandBehavior
> > behavior) [0x00000] 
> >   at
> MySql.Data.MySqlClient.MySqlCommand.ExecuteReader ()
> [0x00000] 
> >   at (wrapper remoting-invoke-with-check)
> > MySql.Data.MySqlClient.MySqlCommand:ExecuteReader
> ()
> >   at MySql.Data.MySqlClient.Driver.ReportWarnings
> () [0x00000]
> >  
> > I receive this error when trying to execute a
> stored procedure (other
> > SQL statements work fine, even other stored
> procedures). It works fine
> > on windows with .NET but on mono (windows or
> linux) I receive that
> > error.
> 
> You're not closing the previous reader. It doesn't
> fail on MS.NET
> because their garbage collector is probably
> disposing the reader
> faster than Mono's.
> 
> Robert
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Mono-list mailing list