try { SqlConnection conn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["ProjectDatabaseConnectionString"].ConnectionString); conn1.Open(); SqlCommand com1; string insertQuery = "update Personal set PersonalEmail = @email,FirstName = @fname, Surname = @sname,TelephoneNo = @telno, Password = @password Where UserName = '" + LblUserName .Text+ "'"; com1 = new SqlCommand(insertQuery, conn1); if (TextBoxNewEmail.Text.Trim() != null) { com1.Parameters.AddWithValue("@email", TextBoxNewEmail.Text); } else { com1.Parameters.AddWithValue("@email", LblOldEmail.Text); //LblOldEmail holds the value of the users old email // TextBoxNewEmail is the textbox where the user enters there new email if they are updating it } com1.Parameters.AddWithValue("@password", TextBoxNewPassword.Text); com1.Parameters.AddWithValue("@fname", TextBoxFirstName.Text); com1.Parameters.AddWithValue("@sname", TextBoxSurName.Text); com1.Parameters.AddWithValue("@telno", TextBoxTelNo.Text); // com1.Parameters.AddWithValue("@location", locID); com1.Parameters.AddWithValue("@conText", RadioButtonListText.SelectedValue); com1.Parameters.AddWithValue("@conEmail", RadioButtonListEmail.SelectedValue); com1.ExecuteNonQuery(); conn1.Close(); Response.Write("Update was successful"); } catch (Exception ex) { Response.Write("error" + ex.ToString()); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)