protected void btnSave_Click(object sender, EventArgs e) { string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; string strUpdate = "UPDATE SignUpTable SET Mobilenumber=@Mobilenumber, DateOfBirth=@DateOfBirth, Gender=@Gender, CurrentCity = @CurrentCity, WHERE Username = @Username"; //Create SQL connection SqlConnection con = new SqlConnection(connectionString); //Create SQL Command And Sql Parameters SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandType = CommandType.Text; cmd.CommandText = strUpdate; SqlParameter Mobilenumber = new SqlParameter("@Mobilenumber", SqlDbType.NVarChar); Mobilenumber.Value = txtMobilenumber.Text.ToString(); cmd.Parameters.Add(Mobilenumber); SqlParameter DateOfBirth = new SqlParameter("@DateOfBirth", SqlDbType.NVarChar); DateOfBirth.Value = txtDOB.Text.ToString(); cmd.Parameters.Add(DateOfBirth); SqlParameter Gender = new SqlParameter("@Gender", SqlDbType.NVarChar); Gender.Value = RadioButtonList1.Text.ToString(); cmd.Parameters.Add(Gender); SqlParameter CurrentCity = new SqlParameter("@CurrentCity", SqlDbType.NVarChar); CurrentCity.Value = txtCurrentCity.Text.ToString(); cmd.Parameters.Add(CurrentCity); SqlParameter Username = new SqlParameter("@Username", SqlDbType.NVarChar); Username.Value = lblEmail.Text.ToString(); cmd.Parameters.Add(Username); try { con.Open(); int result = cmd.ExecuteNonQuery(); //Response.Redirect("About.aspx"); ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert('Saved Successfully')", true); } catch (SqlException ex) { string errorMessage = "Error in updation"; errorMessage += ex.Message; throw new Exception(errorMessage); } finally { con.Close(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)