Sqlserver
 sql >> Base de Dados >  >> RDS >> Sqlserver

Insira a imagem PictureBox no banco de dados do Sql Server


escreva assim:]
Image img = Image.FromFile(@"C:\Lenna.jpg");
byte[] arr;
using (MemoryStream ms = new MemoryStream())
{
    img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
    arr =  ms.ToArray();
}

ou
 Image img = picturebox1.Image();
    byte[] arr;
 ImageConverter converter = new ImageConverter();
   arr=(byte[])converter.ConvertTo(img, typeof(byte[]));

command.CommandText = "INSERT INTO ImagesTable (Image) VALUES('" + arr + "')";
  command.CommandType = CommandType.Text;
  command.ExecuteNonQuery();