views:

40

answers:

1

Hi,

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.

+2  A: 

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.

Remus Rusanu
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.
Chin