Mufid Bagdadi

Mufid Bagdadi

  • NA
  • 146
  • 24.7k

Trying to update table in database in c#

May 10 2016 2:38 AM
It is updating 'locationApproval' but can't  update  'locationComment', please help me for it. 'locationComment' is multiline textbox.
 
protected void update_Click(object sender, EventArgs e)
{
string apr;
string cm;
if (!accept.Checked)
{
apr = "Rejected";
cm = comment.Text;
}
else
{
apr = "Accepted";
cm = comment.Text;
}
if (Session["employee"] != null)
{
try
{
string td = Session["employee"].ToString();
con.Open();
cmd.Connection = con;
cmd.CommandText = "UPDATE appData SET locationApproval = '" + apr + "', locationComment = '" + cm + "' WHERE transactionId = '" + td + "';";
cmd.ExecuteNonQuery();
con.Close();
}
catch (Exception er)
{
Label1.Visible = true;
Label1.Text = er.Message;
}
}
else
{
Label1.Visible = true;
Label1.Text = "Session Error";
}
}

Answers (1)