}//method end..... public void insert_img(std_img_class img) { SqlConnection conn = new SqlConnection(connstring); try { SqlCommand cmd = new SqlCommand("insert_student_img", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@img_path ", SqlDbType.NVarChar).Value = img.img_path; cmd.Parameters.Add("@img_fk ", SqlDbType.Int).Value = img.s_id; conn.Open(); cmd.ExecuteNonQuery(); MessageBox.Show("DATA record has been inserted successfully....."); } catch (Exception) { MessageBox.Show("data is not inserted !!!"); } finally { conn.Close(); } }//method end...
private void button4_Click(object sender, EventArgs e) { std_img_class img = new std_img_class(); img.s_id = Convert.ToInt32(textBox6.Text); img.img_path = textBox5.Text; i.insert_img(img); }