private void btnInsert_Click(object sender, EventArgs e) { try { SqlConnection scon = new SqlConnection("Data Source=ASIC-02\\SQLEXPRESS;Initial Catalog=Student;Integrated Security=True"); scon.Open(); SqlCommand scom = new SqlCommand("rec",scon); scom.CommandType = CommandType.StoredProcedure; scom.Parameters.Add("@Name", SqlDbType.VarChar).Value = txtName.Text; scom.Parameters.Add("@Reg", SqlDbType.VarChar).Value = txtReg.Text; scom.Parameters.Add("@Dep", SqlDbType.VarChar).Value = txtDep.Text; dataGridView1.Rows.Add(txtName.Text, txtReg.Text, txtDep.Text); scom.ExecuteNonQuery(); MessageBox.Show("Information Successfully Inserted"); scon.Close(); this.Refresh(); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)