0

Does anyone know whether it is possible to change the DateTimeMode when using a DataReader. All the examples, as below, I can find use a DataTable.

SqlCommand command = new SqlCommand("SELECT EmployeeID, FullName, DateCreated,           DateAppointment FROM [Employees] ...", connection);
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataTable result = new DataTable();
adapter.FillSchema(result, SchemaType.Source);
result.Columns["DateCreated"].DateTimeMode = DataSetDateTime.Utc;
result.Columns["DateAppointment"].DateTimeMode = DataSetDateTime.Utc;
adapter.Fill(result);
return result;

Would I be better going to a DataTable? Any pointers much appreciated.

1 Answer 1

2

If your question is whether you can avoid setting the UTC mode explicitly every time, then you should use a strongly typed data set and set the mode in the designer.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I very rarely use VS so was just hoping for a way of making sure I got UTC dates back via an existing method call to the db.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.