So below I have a piece of code that I have been working on:
SqlConnection connect = new SqlConnection("Server=OMADB01;Database=PATRICK_DEV;Trusted_Connection=True;");
connect.Open();
SqlCommand command = new SqlCommand("UPDATE FILE_DATE_PROCESSED SET FILE_DATE_PROCESSED = DATE_ENTERED, DATE_ENTERED = GETDATE() SELECT top 1 FILE_DATE_PROCESSED, DATE_ENTERED FROM FILE_DATE_PROCESSED, ORDER BY DATE_ENTERED DESC ", connect);
SqlDataReader reader = null;
reader = command.ExecuteReader();
while (reader.Read())
{
Console.WriteLine(reader["FILE_DATE_PROCESSED"].ToString());
Console.WriteLine(reader["DATE_ENTERED"].ToString());
}
connect.Close();
This code is supposed to write out the contents of the datatable I have in SQL, however I keep getting an error message that ORDER is incorrect syntax, however that is false because when I take that statement and put it in my query in SQL, it works. I am new to using SQL in c# so I am not quite sure how to debug with SQL statements, so if someone could please help me figure this out I would very much appreciate it!
updatewhich depends on the value of aselectfrom the same table (and depends ongetdate()) - in which case you shouldn't need the select at all