} //method end...................... public void insert_img(std_imgclass 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 button3_Click(object sender, EventArgs e) { std_imgclass img = new std_imgclass(); img.s_id = Convert.ToInt32(textBox4.Text); img.img_path = textBox3.Text; i.insert_img(img); textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); textBox4.Clear(); textBox5.Clear(); richTextBox1.Clear(); }