Progress!...But wait...

03/27/2012 23:17 bryce16#1
I managed to fix up the connections inbound/outbound throughout my learning project and a few other things I learned from this forum so +1 for epvp xd
Anyway, I'm stuck on newb-mode at the moment and I can't seem to find the solution for this very common-yet annoying error located in the KillConnection file. It's quite large but I'll post it here anyway, This isn't my work. Credit goes to the original coder of this file. I simply need assistance in obtaining the solution.
Code:
using System;
using System.Data;
using MySql.Data.MySqlClient;
using System.Collections.Generic;

public class KillConnections
{
    public static void Kill()
    {
        string command = "SHOW processlist";
        List<ulong> processes = new List<ulong>();

        MySqlConnection conn = new MySqlConnection(MySqlCmd.ConnectionString);
        MySqlCommand cmd = new MySqlCommand(command, conn);
        MySqlDataReader reader = null;

        try
        {
            conn.Open();
            reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                ulong identity = ulong.Parse(reader["Id"].ToString());
                if (reader["Command"].ToString() == "Sleep"
                                    && uint.Parse(reader["Time"].ToString()) >= conn.ConnectionTimeout
                                    && identity > 0)
                    processes.Add(identity);
            }
            reader.Close();
            reader.Dispose();
            reader = null;

            foreach (int identity in processes)
            {
                command = "KILL " + identity;
                cmd.CommandText = command;
                cmd.ExecuteNonQuery();
            }
            cmd.Dispose();
            cmd = null;
        }

        catch (Exception e)
        {
            Console.WriteLine(e);
        }

        finally
        {
            if (reader != null && !reader.IsClosed)
            {
                reader.Close();
                reader.Dispose();
                reader = null;
            }
            if (conn != null && conn.State == ConnectionState.Open)
            {
                conn.Close();
                conn.Dispose();
            }
            if (cmd != null)
            {
                cmd.Dispose();
                cmd = null;
            }
        }
    }
}
Code:
Error	 1: The name 'MySqlCmd' does not exist in the current context
03/28/2012 02:35 Spirited#2
I'm the original coder. Basically, I created that for my Project Kibou source. You need to implement it into your source. In other words, you need to know enough about your source to convert it to work with your methods. Good luck!
03/28/2012 03:00 shadowman123#3
Quote:
Originally Posted by Fаng View Post
I'm the original coder. Basically, I created that for my Project Kibou source. You need to implement it into your source. In other words, you need to know enough about your source to convert it to work with your methods. Good luck!
well in The Source im using it contained this KillConnection Class and handled but the question is what does it do actualy ?
03/28/2012 04:09 Spirited#4
Quote:
Originally Posted by shadowman123 View Post
well in The Source im using it contained this KillConnection Class and handled but the question is what does it do actualy ?
Look up what a sleeping sql connection is.
03/29/2012 00:49 bryce16#5
Successfully converted. =p
#Request Closed