Hi! I don't know what's wrong with my code. It doesn't have any errors, but when I run it on a browser and tried to update the database when clicking the "submit button", the database was not updated at all with the changes I made. I hope someone could help me find out why I couldn't save changes to the database.
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (ValidateInfo())
{
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=ALLAINE-PC\SQLEXPRESS;Initial Catalog=cmsdatabase;Integrated Security=True";
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "update CaseDatabase set CONAME='" + txtName.Text + "',COADDRESS='" + txtAddress.Text + "',CONTACTPERSON='"
+ txtContact.Text + "',TELNO='"
+ txtTel.Text + "',EMAIL='"
+ txtEmail.Text + "',OPDATE='"
+ txtDate.Text + "',LEFT_SANDZ='"
+ txtLeft.Text + "',TIME_ARRIVED='"
+ txtArrived.Text + "',TIME_LEFT='"
+ txtLeftSite.Text + "',SYSTYPE='"
+ txtSysType.Text + "',MODEL='"
+ txtModel.Text + "',OS='"
+ txtOS.Text + "',SERIALNO='"
+ txtSerial.Text + "',PROBLEM='"
+ txtProblem.Text + "',ACTION_TAKEN='"
+ txtAction.Text + "',TICKETSTATUS='"
+ txtStatus.Text + "',LASTUPDATE='"
+ txtLastUpdate.Text + "',SYSENG='"
+ txtSE.Text + "' where TICKETNO='" + txtTicket.Text + "'";
cmd.Connection = con;
SqlDataAdapter da = new SqlDataAdapter();
da.UpdateCommand = cmd;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
lblError.Font.Bold = true;
lblError.Font.Size = 11;
lblError.Text = "You have successfully modified the case!";
}
}