Please help, I have a problem updating a bit datatype with asp.net webpages syntax. Here's my code
var db = Database.Open("StarterSite");
var idAdmin = ""; // Here's the ID of the new Admin
var idAdmin2 = ""; // Here's The ID of the old Admin
if(!IsPost){
if(!Request.QueryString["id"].IsEmpty() && Request.QueryString["id"].IsInt()) {
diklatid = Request.QueryString["id"];
var dbCommand = "SELECT * FROM diklat WHERE ID_diklat = @0";
var row = db.QuerySingle(dbCommand, diklatid);
if(row != null) {
string rowidadmin = row.ID_Admin.ToString();
idAdmin2 = rowidadmin; // Inserted the ID value of old admin to this variable
}
else{
Validation.AddFormError("No data choosen");
}
}
else{
Validation.AddFormError("No data choosen");
}
}
if(IsPost){
idAdmin = Request.Form["idAdmin"]; //The ID value of new admin comes from the Form
if (idAdmin == idAdmin2){
//Check if the new admin equals to old admin
-------------------//do something------
Response.Redirect("~/SuperAdmin/diklat");
}
else
{
//-----------------------------The Main Problem------------------------
// If different it suppose to change "onDuty" variable of the new one to 1 (true) and the old one to 0 (false)
var updateCommand1 = "UPDATE UserProfile SET onDuty= 0 WHERE UserId=@0";
db.Execute(updateCommand1, idAdmin2);
var updateCommand2 = "UPDATE UserProfile SET onDuty= 1 WHERE UserId=@0";
db.Execute(updateCommand2, idAdmin);
Response.Redirect("~/SuperAdmin/diklat");
}
The modules suppose to do this : Editing the status of Admin (On duty or not) in bit datatype. The Situation I'm having is Once the admin is updated to the new one, The onDuty which is bit datatype of the old one won't update to 0 (from 1) but the new one successfully updated to 1 (from 0). Sorry for the long code, The problem is simple, but I just want to make sure this problem doesn't come from anywhere else from my code. Hope it's clear enough
Note : There's no error announcement at all! The page still works, only the data in the database is not updated