Converting DateTime results in IndexOutOfRangeException
Time =(DateTime) AllQuestionsPresented.TryParse(dr["Time"].ToString());
Where dr
is a SqlReader.
I get an IndexOutOfRangeException
and I don't know why. Here is the TryParse function:
public static DateTime? TryParse(string text)
{
DateTime date;
if (DateTime.TryParse(text, out date))
{
return date;
}
else
{
retu开发者_如何学JAVArn null;
}
}
I don't understand why I get that exception and how could i get rid of it?!
It might mean that it can't be found in reader. Does dr
have column with name "Time"?
精彩评论