A generic error occurred in GDI+ is showing when I am trying to save student records with an image
I have already tried to save the image in the folder named student_images
[enter image description here][1][enter image description here][1]
private void button2_Click(object sender, EventArgs e)
{
try {
var connectionString = Utilities.ConnectionStringWindow;
SqlConnection con = new SqlConnection(connectionString);
string img_path;
var wanted_path = AppDomain.CurrentDomain.BaseDirectory;
pictureBox1.Image.Save(wanted_path + "\\student_images\\" + pwd + ".jpg");
//File.Copy(pictureBox1.ImageLocation, wanted_path + "\\student_images\\" + pwd + ".jpg");
img_path = "\\student_images\\" + pwd + ".jpg";
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "insert into student_info (student_name,student_image,student_enrollment_no,student_department,student_sem,student_contact_no,student_email) values('" + textBox1.Text + "','" + img_path.ToString() + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "')";
cmd.ExecuteNonQuery();
MessageBox.Show("record inserted successfully");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}