paddu v

paddu v

  • NA
  • 53
  • 49.6k

How to insert image into Database,In database profilepic datatype is varBinary(Max)

Jun 28 2012 9:37 AM
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

Answers (2)