Skip to content

Instantly share code, notes, and snippets.

@riccardopirani
Created January 9, 2018 15:45
Show Gist options
  • Select an option

  • Save riccardopirani/3860d155be714bdcd659dc2ca23d97d3 to your computer and use it in GitHub Desktop.

Select an option

Save riccardopirani/3860d155be714bdcd659dc2ca23d97d3 to your computer and use it in GitHub Desktop.
Errore GDI+ system.runtime.interopservices.externalexception
byte[] photo_aray = new byte[0];
try
{
//inserimento immagine di una distinta
MemoryStream ms;
ms = new MemoryStream();
pictureBoxCheckImmagine.Image.Save(ms, ImageFormat.Jpeg);
photo_aray = new byte[ms.Length];
ms.Position = 0;
ms.Read(photo_aray, 0, photo_aray.Length);
cmdIns.Parameters.Add("@Images", SqlDbType.Binary).Value = photo_aray;
}
catch (Exception ex)
{
MessageBox.Show("Non ho inserito l'immagine: " + ex);
cmdIns.Parameters.Add("@Images", SqlDbType.Binary).Value = photo_aray;
Managementerror.SendError(ex.ToString());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment