How to insert image into Database,In database profilepic datatype is varBinary(Max)
private void btnBrowse_Click(object sender, EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.Title = "Open Photo";
dlg.Filter = "jpg files(*.jpg|*.jpg|All files(*.*)|*.*";
if (dlg.ShowDialog() == DialogResult.OK)
{
pictureBox1.Image = new Bitmap(dlg.OpenFile());
}
dlg.Dispose();
}
private void btnAdd_Click(object sender,EventArgs e)
{
MemoryStream ms = new MemoryStream();
pictureBox1.Image.Save(ms, ImageFormat.Jpeg);
ms.Position = 0;
ms.Read(photo, 0, Convert.ToInt32(photo.Length));
pinfo.profilepic=photo//here i am getting error why because the datatype convertion problem.photo is Byte[] type and profilepic is Binary type
}
please give me answer