Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SqlConnection con = new SqlConnection();
- con.ConnectionString = ConfigurationManager.ConnectionStrings["studentCS"].ConnectionString;
- string name = tb_name.Text;
- string adminno = tb_admno.Text;
- string telephone = tb_telno.Text;
- string height = tb_height.Text;
- string sql = "Update studentTable Set studName=@pStudName, telephone=@pTelephone, heightCM=@pHeightCM";
- sql = sql + " where adminNo= '" + ddl_adminno.SelectedValue + "'";
- SqlCommand cmd = new SqlCommand(sql, con);
- cmd.Parameters.AddWithValue("@pStudName", tb_name.Text);
- cmd.Parameters.AddWithValue("@pAdminNo", tb_admno.Text);
- cmd.Parameters.AddWithValue("@pTelephone", tb_telno.Text);
- cmd.Parameters.AddWithValue("@pHeightCM", tb_height.Text);
- try
- {
- con.Open();
- cmd.ExecuteNonQuery();
- lb_msg.Text = "Record updated successfully";
- }
- catch (Exception ex)
- {
- lb_msg.Text = "Problem encountered:" + ex.Message;
- }
- finally
- {
- con.Close();
- con.Dispose();
- cmd.Dispose();
- }
Add Comment
Please, Sign In to add comment