I need to update my database to set a date to the current timestamp. However, my ExecuteNonQuery is giving an exception "Incorrect syntax near ')' ". Can anyone tell me what is wrong? This is the function with the error:
protected void setprint(object sender, EventArgs ev)
{
GridViewRow row = ((LinkButton)sender).Parent.Parent as GridViewRow;
inv = row.Cells[1].ToString().Trim();
con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
cmd = new SqlCommand("update invdata set ViewDate = CURRENT_TIMESTAMP() where InvoiceNumber= '" + inv + "'", con);
try
{
con.Open();
cmd.ExecuteNonQuery();
}
finally
{
if (con != null)
con.Close();
}
}