title: Error-Unable to cast object of type 'System.Byte[]' to type 'System.IConvertible'
body: <p>I am developing an application to transfer data between two databases in C#. I have a method to insert BLOB type data in MySQL. While executing it I am getting error <code>Unable to cast object of type 'System.Byte[]' to type 'System.IConvertible'.</code></p>
  
  <p>Code#</p>
  
  <pre><code>public static void FiletoSql(MemoryStream fileToPut, MySqlConnection con)
      {
        try
        {
         const string preparedCommand =
         @"update user_account_statement set STATEMENT_FILE=@ssfile, create_date_time=@udatetime where statement_Id=1070";
         using (var sqlWrite = new MySqlCommand(preparedCommand, con))
         {
           sqlWrite.Parameters.AddWithValue("@ssfile", MySqlDbType.Blob).Value = fileToPut.ToArray();
           sqlWrite.Parameters.AddWithValue("@udatetime", MySqlDbType.DateTime).Value =
           DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
           sqlWrite.ExecuteNonQuery();
         }
        }
      catch (Exception ex)
       {
        MessageBox.Show(ex.ToString());
       }
     }
  </code></pre>
  
  <p>I am not getting exactly what is problem in converting.</p>
  
  <p><strong>Edit</strong>: I've tried this:</p>
  
  <pre><code>var fileData=new MySqlParameter("@ssfile",MySqlDbType.Blob,data.Length) {
      Value = data
  };
  sqlWrite.Parameters.Add(fileData);
  sqlWrite.Parameters.AddWithValue("@udatetime", MySqlDbType.DateTime)
                     .Value = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
  var cmd = sqlWrite;
  sqlWrite.ExecuteNonQuery();
  </code></pre>
  
  <p>And now I am getting error Input string was not in a correct format.</p>