ازاین ارور میگیره


dataGridView1.DataBind();

این هم کد عکس


private void button2_Click(object sender, EventArgs e)
{
if (txtn.Text != "" & txtfn.Text != "" & txtshsh.Text != "" & txtid.Text != "" & radf.Text != "" & txtin.Text != "" & txtsal.Text != "" & txtnu.Text != "" & txtem.Text != "" & txtav.Text != "" & txtj.Text != "" & txtadd.Text != "" )
{
cn.Open();
cmd.CommandText = "insert into student (name,fname,shsh,id,field,input,year,tnumber,email ,average,jensiat,address,image) values (N'" + txtn.Text + "',N'" + txtfn.Text + "',N'" + txtshsh.Text + "',N'" + txtid.Text + "',N'" + radf.Text + "',N'" + txtin.Text + "',N'" + txtsal.Text + "',N'" + txtnu.Text + "',N'" + txtem.Text + "',N'" + txtav.Text + "',N'" + txtj.Text + "',N'" + txtadd + "',@image)";
cmd.Parameters.AddWithValue("@image", ImageToByte(pictureBox1.Image));
cmd.ExecuteNonQuery();
cmd.Clone();
MessageBox.Show("اطلاهات با موفقیت ثبت شد", "ثبت اطلاعات");
cn.Close();
txtn.Text = "";
txtfn.Text = "";
txtshsh.Text = "";
txtid.Text = "";
radf.Text = "";
txtin.Text = "";
txtsal.Text = "";
txtnu.Text = "";
txtem.Text = "";
txtav.Text = "";
txtj.Text = "";
txtadd.Text = "";
loadlist();

////////////دکمه انتخاب عکس
OpenFileDialog OpenFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "Image Files|*.bmp;*.jpg;*.jpeg;*.png;*.gif ";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
pictureBox1.Image = new Bitmap(openFileDialog1.FileName);

txtimage.Text = openFileDialog1.SafeFileName;
pictureBox1.ImageLocation = openFileDialog1.FileName;
}

این هم تبدیلش به باینری

public static byte[] ImageToByte(Image img)
{
ImageConverter converter = new ImageConverter();
return (byte[])converter.ConvertTo(img, typeof(byte[]));


}