Thursday, May 9, 2013

Strange behavior in datatable

Hi, I have a datatable with a column of type datetime, there is a situation where someone assign a message in this column, something like "hello world", and it´s not throwing an exception. I know that should not be, I can´t find a why it happens.


I check the column of the table in the database and its type is smalldatetime, also check the store procedure that brings data, and makes no conversion, finally, it uses a datareader to get data


Any idea why not throw the exception?




Datatable lobjTable = lobjPrest.FindData();


if (lobjTable != null && lobjTable.Rows.Count > 0) {


lobjTable.Rows[0]["Date"] = "Hello world"; //This column had datetime format


}


No comments:

Post a Comment