title: ERROR [HY000] [MySQL][ODBC 3.51 Driver]Can't connect to MySQL server on 'localhost' (10048)
body: <p>I am using the MySQL ODBC (3.51) connector for Windows in my application. I have a loop that continuously opens and closes a connection to my MySQL server running on <code>Localhost</code>. After some time and after successful connections and updates, out of the blue, I get the following exception:</p>
  
  <pre><code>ERROR [HY000] [MySQL][ODBC 3.51 Driver]Can't connect to MySQL server on 'localhost' (10048)
  </code></pre>
  
  <p>Why is this?</p>
  
  <p>Here is a sample of my code:</p>
  
  <pre><code>for(;i&lt;_queue.Count;i++)
  {
    opcdatastructure.opcservertags opctag = _queue.Dequeue();
    update(opctag.value, opctag.filetimestamp, opctag.tagtimestamp, 
           opctag.quality, opctag.itemID);
  }
  
  public void update(string value,string filetimestamp,DateTime tagtimestamp,
                     int quality,int itemID)
  {
    try
    {
      lock (myLockHolder)
      {
         X1 = 1;
         OdbcConnection con = 
           new OdbcConnection(LocalConnection.GetLocalConnetionString());
         OdbcCommand cmd;                    
         string query = "";
         query = "update parameter" + Environment.NewLine;
         query += "set paramvalue='" + value + "',date_logged1='" + filetimestamp +
                  "',Quality='" + quality + "',date_logged='" + tagtimestamp + "'" + 
                  Environment.NewLine;
         query += " where itemID='" + itemID + "'";
         if (con.State == ConnectionState.Closed)
             con.Open();
         cmd = new OdbcCommand(query, con);
         cmd.ExecuteNonQuery();
         if (con.State == ConnectionState.Open)
             con.Close();
      }
    }
    catch { }
  }
  </code></pre>