开发者

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"?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜