I'm using Visual Studio 2010 (C#) with mysqlConnector and everything appears to become fine. However, after i attempt to request something in the server I recieve this error:

"There's already a wide open DataReader connected with this particular Connection which should be closed first."

This really is my code:

gc.connect();

List<Conseiller> conseillers = gc.getAllConseillers();

--

public void connect() 
{
    string connStr = "SERVER=localhost;UID=root;DATABASE=Projet;Password=root";
    oConn = new MySqlConnection(connStr);

    try 
    {
        oConn.Open();
        Console.WriteLine("Successfully connected to the data base");
    } 
    catch (OdbcException caugth) 
    {
        /* Traitement de l'erreur */
        Console.WriteLine(caugth.Message);
    }
}

-- 

public List<Conseiller> getAllConseillers()
{
    MySqlCommand oComm = oConn.CreateCommand();

    oComm = oConn.CreateCommand();

    Console.WriteLine("SELECT * FROM conseillers");
    oComm.CommandText = "SELECT * FROM conseillers";

    MySqlDataReader oReader = oComm.ExecuteReader(); // Error here
}

Where I'm wrong ?

You are not getting rid of of the objects, which essentially implies that your previous call to getAllConseillers, or perhaps a similar method, opened up an information readers that's still open.

The next objects inside your question are disposable (ie. implements IDisposable), you need to dispose of all of them:

  1. MySqlConnection
  2. MySqlCommand
  3. MySqlDataReader

Essentially, I'd alter the code as proven for this:

using (var gc = new Whatever())
{
    gc.connect();
    List<Conseiller> conseillers = gc.getAllConseillers();
}

--

public void connect()
{
    string connStr = "SERVER=localhost;UID=root;DATABASE=Projet;Password=root";
    oConn = new MySqlConnection(connStr);
    try
    {
        oConn.Open();
        Console.WriteLine("Successfully connected to the data base");
    }
    catch (OdbcException ex)
    {
        /* Traitement de l'erreur */
        Console.WriteLine(ex.Message);
        oConn.Dispose();
        oConn = null;
        // optional: throw;
    }
}

-- 

public List<Conseiller> getAllConseillers()
{
    using (MySqlCommand oComm = oConn.CreateCommand())
    {
        Console.WriteLine("SELECT * FROM conseillers");
        oComm.CommandText = "SELECT * FROM conseillers";
        using (MySqlDataReader oReader = oComm.ExecuteReader()) // No error here
        {
            // process the result in oReader here
            return ...;
        }
        ...
    }
    ...
}

A couple of suggestions that might help:

First, inside your code above you've known as CreateCommand two times and don't have to.

Secon, you are able to instantiate your Command quite different to create this simpler to see:

MySqlCommand oComm = new MySqlCommand("Select * from conseillers", oConn);

then call the ExecuteReader.

Third, your code above does not show once the connection is open. Are you certain it's open? Are you certain you have not already known as an information readers using the open connection and did not close it?

4th, it is best to open the bond as late as you possibly can and close it as soon as possible. The code you've appears like you will open the bond and then leave it open but I am not necessarily certain of your intent.

I recommend while using Using syntax:

Using connection As New SqlConnection(connectionString)
        Dim command As New SqlCommand(queryString, connection)
        connection.Open()
        Dim reader As SqlDataReader = command.ExecuteReader()
        Try
            While reader.Read()
                Console.WriteLine(String.Format("{0}, {1}", _
                    reader(0), reader(1)))
            End While
        Finally
            ' Always call Close when done reading.
            reader.Close()
        End Try
    End Using

Customize the above code for the situation....