c# - cannot update database without error -


part 1, code below function class.

public static void updatedata(string sqlcommand) {     string strconstring = configurationmanager.connectionstrings["soconnectionstring"].connectionstring;     oledbconnection conn = new oledbconnection(strconstring);     oledbcommand cmd = new oledbcommand(sqlcommand, conn);      try {         conn.open();         cmd.executenonquery();         conn.close();     }     catch (exception e)     {         conn.close();      }    } 

here code call function above.

protected void imagebutton2_click(object sender, imageclickeventargs e)         {              string id = txtid.text;             string password = txtpassword.text;             string name = txtname.text;             string position = txtposition.text;             int status = 1;             string createon = validate.gettimestamp(datetime.now); ;             string accessright;             if (radiobutton1.checked)                 accessright = "administrator";             else                 accessright = "non-administrator";              //    clientscript.registerstartupscript(this.gettype(), "yourmessage", "alert('" + id + "ha " + password + "ha " + status + "ha " + accessright + "ha " + position + "ha " + name + "ha " + createon + "');", true);              string type = (string)session["type"];               if (type == "update")                 {                     string sqlcommand = "update usermaster set userposition='"+position+"',username='"+name+"' (userid ='"+id+"')";                     readdata.updatedata(sqlcommand);                     response.redirect("userview.aspx");                 }              else {                                  if (validate.verifyid(id) == true)                     {                         if (validate.verifylang((string)session["lang"]) == true)                             lbliderror.text = "user id exist!";                         else                             lbliderror.text = "用户账号已存在!";                     }                     else{                         string sqlcommand = "insert usermaster (userid,userpwd,username,userposition,useraccessrights,userstatus,createdate,createuserid) values ('" + id + "','" + password + "','" + name + "','" + position + "','" + accessright + "','" + status + "', to_date('" + createon + "'),'" + (string)session["userid"] + "')";                         readdata.updatedata(sqlcommand);                         response.redirect("userview.aspx");                      }                 }             } 

part 1 code running insert, when come update, doesnt show me error , doesnt update data. know wrong code?

probably value used in update statements condition missing value.you can find using breakers,that might give idea finding answer,as dont know let me post here how break , find them.

below picture break , view query value.

enter image description here

enter image description here


Comments