转换DateTime会导致IndexOutOfRangeException

Mat*_*001 2 c# sql indexoutofboundsexception

Time =(DateTime) AllQuestionsPresented.TryParse(dr["Time"].ToString());
Run Code Online (Sandbox Code Playgroud)

哪里dr是SqlReader.

我得到了一个IndexOutOfRangeException,我不知道为什么.这是TryParse函数:

public static DateTime? TryParse(string text)
{
    DateTime date;
    if (DateTime.TryParse(text, out date))
    {
        return date;
    }
    else
    {
        return null;
    }
}
Run Code Online (Sandbox Code Playgroud)

我不明白为什么我得到那个例外,我怎么能摆脱它?!

Pio*_*cik 8

这可能意味着它无法在读者中找到.是否dr有名为"时间"的列?