这意味着什么'对象引用未设置为对象的实例'?

时间:2014-05-13 14:08:35

标签: c#

以下是我的代码。此代码显示错误"对象引用未设置为对象的实例"。这个错误意味着什么,我该如何解决?

public string ShowRoutineSubjectCode(string class_days)
{

    try
    {
        ConnectionObj.Open();
        string query = "SELECT course_code FROM course_table,course_teacher_table WHERE course_table.course_id = course_teacher_table.c_id AND class_days = '"+class_days+"'";
        CommandObj.CommandText = query;
        return CommandObj.ExecuteScalar().ToString();
    }
    catch (Exception ex)
    {
        throw ex;
    }
    finally
    { //here shows that error 
        if (ConnectionObj != null && ConnectionObj.State == ConnectionState.Open) 
        {
            ConnectionObj.Close();  
        }
    }
}

0 个答案:

没有答案