I would try putting a breakpoint at the beginning of this code behind and F11 through it to see where its bombing out. One thing I can suggest is move your connection.Close(); to after the catch block since that will leave the connection open. So your code
will look more like this:
bbcompent1
All-Star
32982 Points
8508 Posts
Moderator
Re: Using html5 contentEditable to save to db
Apr 12, 2012 03:25 PM|LINK
I would try putting a breakpoint at the beginning of this code behind and F11 through it to see where its bombing out. One thing I can suggest is move your connection.Close(); to after the catch block since that will leave the connection open. So your code will look more like this:
string newName; string newIntro; string newEduc; string newWork; newName = h1.Text; newIntro = intro.Text; newEduc = educ.Text; newWork = employ.Text; string connectionInfo = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString; using (SqlConnection connection = new SqlConnection(connectionInfo)) { connection.Open(); SqlCommand myCommand = new SqlCommand("UPDATE simpleContent SET userName = @newName, infoContent = @newIntro, educContent = @newEduc, workContent = @newWork WHERE userID = @userName", connection); try { string username = HttpContext.Current.User.Identity.Name; myCommand.Parameters.AddWithValue("@userName", username.ToString()); myCommand.Parameters.AddWithValue("@newName", newName.ToString()); myCommand.Parameters.AddWithValue("@newIntro", newIntro.ToString()); myCommand.Parameters.AddWithValue("@newEduc", newEduc.ToString()); myCommand.Parameters.AddWithValue("@newWork", newWork.ToString()); myCommand.ExecuteNonQuery(); } catch { Response.Redirect("http://www.google.co.uk"); } connection.Close(); } }