title: MySQL System.FormatException: Input string was not in a correct format
body: <p>Currently, I am creating an application using ASP.NET MVC3 and MySQL and when I try to retrieve a user's first name from the databse I receive a System.FormatException: Input string was not in a correct format.</p>
  
  <p>This is my code:</p>
  
  <pre><code>public string GetUserFirstName(UInt64 id)
  {
     DBConnections databaseCnnString = new DBConnections();
     string connectionString = "server=123.123.com;user=me;database=db1;port=3306;password=abcdef";
     MySqlConnection cnn = new MySqlConnection(connectionString);
  
     try
     {
        cnn.Open();
        string sp_GetFName = "SP_GET_FNAME";
        MySqlCommand cmd = new MySqlCommand(sp_GetFName, cnn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("id", id);
        cmd.Parameters["id"].Direction = ParameterDirection.Input;
        cmd.Parameters.AddWithValue("first_name", MySqlDbType.VarChar);
        cmd.Parameters["first_name"].Direction = ParameterDirection.Output;
  
        object result = cmd.ExecuteScalar();
        if (result != null)
        {
           string fname = Convert.ToString(result);
           return fname; 
        }
        else
        {
           string fname = "friend";
           return fname; 
        }
  
     }
     catch (Exception ex)
     {
        throw (ex);
     }
     finally
     {
        cnn.Close();
        cnn.Dispose();
     }
  }
  </code></pre>
  
  <p>This is MySQL Stored Procedure:</p>
  
  <pre><code>CREATE DEFINER=`0001`@`%` PROCEDURE `SP_GET_FNAME`(IN id BIGINT(20), OUT first_name VARCHAR(60))
  BEGIN
      DECLARE user_id BIGINT(20) DEFAULT id;
      DECLARE output VARCHAR(60);
      SELECT `FName` FROM `users` WHERE USERID=user_id INTO output;
      SET first_name = output;
  END
  </code></pre>
  
  <p>The problem seems to be when executing cmd.ExecuteScalar().</p>
  
  <p>What is my problem here?</p>
  
  <p>Thank you in advance!</p>