Hello i have a problem with my application today it encountered a major problem :
I'm using vs2008 prof with it's sql server 2005 express edition.
The problem is that when i try to make an update on a row in one table the update.executeNonQuery() returns the value 1 that means that there was 1 row updated but the row is not updated.
If i try to modify the value manually by opening the table data and modifying a field it works and it saves but otherwise it does nothing.
I also tried to run it on a different machine with the same software kit and the same thing also tried to run it by IIS7 and the problem is not going away.
Can anybody give some suggestions of what should i do or if anyone encountered this problem i really need the help and i will highly appreciate it!
Later Edit : -- Added the source code
int user_id = (int)Session["UserId"];
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
con.Open();
SqlCommand update = new SqlCommand("update profil_candidat set nume = @pnume, prenume = @pprenume, data_nasterii = @pdata_nasterii, id_oras = @pid_oras , adresa = @padresa where id_utilizator=@pid_utilizator",con);
update.Parameters.Add("pnume", SqlDbType.VarChar);
update.Parameters.Add("pprenume", SqlDbType.VarChar);
update.Parameters.Add("pdata_nasterii", SqlDbType.VarChar);
update.Parameters.Add("pid_oras", SqlDbType.VarChar);
update.Parameters.Add("padresa", SqlDbType.VarChar);
update.Parameters.Add("pid_utilizator",SqlDbType.Int);
int an = Convert.ToInt32(AnDropDownList.SelectedItem.Value);
int luna = Convert.ToInt32(LunaDropDownList.SelectedItem.Value);
int zi = Convert.ToInt32(ZiDropDownList.SelectedItem.Value);
DateTime data = new DateTime(an, luna, zi);
update.Parameters["pnume"].Value = TextBoxNume.Text;
update.Parameters["pprenume"].Value = TextBoxPrenume.Text;
update.Parameters["pdata_nasterii"].Value = data;
update.Parameters["pid_oras"].Value = DropDownList1.SelectedItem.Value;
update.Parameters["padresa"].Value = TextBoxAdresa.Text;
update.Parameters["pid_utilizator"].Value = int.Parse(Session["UserId"].ToString());
update.ExecuteNonQuery();
con.Close();
Later edit
Issue solved seems that in fact it was related to :
C# Update Table using SqlCommand.Parameters ASP.NET
somebody forgot to put the form initialization in the page load in an if(Page.IsPostBack) and there was nothing wrong with the dbase but the parameters sent in the statement were always preloaded on event... still thank you for the prompt answers !