vendredi 8 mai 2015

Data is not updating into database

I want to update the values of textboxes into my database.

The code does not show any syntax error and redirects easily to the page I'm redirecting but still database is not updating the new data in it.

conn.Open();
string str_id = Session["userid"].ToString();
int id;
id = Convert.ToInt32(str_id);
id = Int32.Parse(str_id);

string updatequery = "Update empdata set fname='" + updatename.Text + "',education='" + updateeducation.Text + "',position='" + updateposition.Text + "',email='" + updateemail.Text + "',address='" + updateaddress.Text + "',contact='" + updatecontact.Text + "',account='" + updateaccount.Text + "',postal='" + updatepostal.Text + "',password = '" + updatepwd.Text + "' Where id = '" +id.ToString()+ "'";
SqlCommand updateinfo = new SqlCommand(updatequery, conn);
updateinfo.ExecuteNonQuery();
updateinfo.Dispose();
updationmessage.Text="<p style='color:green;'>Information updated successfully</p>";

Aucun commentaire:

Enregistrer un commentaire