sql >> Base de Datos >  >> RDS >> Sqlserver

Inserte la imagen de PictureBox en la base de datos del servidor Sql

escribir de esta manera:]

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();
}

o

 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();