Hi @gal mor ,
I think you can try the following way of writing, it should reduce the workload a little, if there are new columns you only need to add two places.
if (OldName != NAME || oldCreated != DATE || new columns )
{
if(OldName == NAME)
{
SqlCommand cmd = new SqlCommand("Update Test set Date='" + DATE + "' where ID=" + Convert.ToInt32(id.Text), con);
c m d.ExecuteNonQuery();
}
if(oldCreated == DATE)
{
SqlCommand cmd = new SqlCommand("Update Test set Name='" + NAME + "' where ID=" + Convert.ToInt32(id.Text), con);
c m d.ExecuteNonQuery();
}
if (new columns )
{
}
}
else
{
SqlCommand cmd = new SqlCommand("Update Test set Name='" + NAME + "',Date='" + DATE + "' where ID=" + Convert.ToInt32(id.Text), con);
c m d.ExecuteNonQuery();
}
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.