title: Retrieve LONGBLOB from MySQL in C#
body: <p>I want to retrieve a LONGBLOB from my MySQL database but I don't know how. I have searched the interwebz and nothing really helpful (understandable) was found. When I retrieve the LONGBLOB, I want to save it as a image.</p>
  
  <p>This is what I already tried:</p>
  
  <pre><code>        int bufferSize = 100;
          byte[] bin = new byte[bufferSize];
          long retval = 0;
          long startIndex = 0;
  
          MemoryStream ms = null;
          Image image = null;
  
          MySqlCommand command = new MySqlCommand("select * from image where uid = @uid", Connection.Connect());
          command.Parameters.AddWithValue("@uid", "2");
          MySqlDataReader reader = command.ExecuteReader();
  
          if (reader.Read())
          {
              retval = reader.GetBytes(reader.GetOrdinal("logo"), startIndex, bin, 0, bufferSize);
          }
  
  
          ms = new MemoryStream(bin);
          image = Image.FromStream(ms);
  </code></pre>
  
  <p>Thanks in advance.</p>