Declare this variable:
----------------------
Byte[] b = null;
FileStream Fs = default(FileStream);
click the pictureBox1 then write this coding:
---------------------------------------------
private void PictureBox1_Click(object sender, EventArgs e)
{
try
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Filter = "JPEG(*.jpeg)|*.jpeg|GIF(*.gif)|*.gif|PNG(*.Png)|*.png|AllFiles|*.*";
if (dialog.ShowDialog() == DialogResult.OK)
{
Fs = File.Open(dialog.FileName, FileMode.OpenOrCreate);
b = new Byte[Fs.Length];
Fs.Read(b, 0, b.Length);
Fs.Close();
IMG.Image = Image.FromFile(dialog.FileName);
}
else
{
MessageBox.Show("Select Image", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
Click save Button:
-----------
SqlCmd.Parameters.AddWithValue("@img", b);