数据库连接时老是提示"未将对象引用设置到对象的实例。"请问下是什么原因啊?
抱错是这样的:
未将对象引用设置到对象的实例。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。
源错误:
行 28: string strCommand = "select top 1 Country from users order by userid desc";
行 29: SqlCommand command = new SqlCommand(strCommand,connection);
行 30: connection.Open();
行 31: if(command.ExecuteScalar() != System.DBNull.Value || command.ExecuteScalar().ToString() != string.Empty)
行 32: {
源文件: c:\inetpub\wwwroot\webapplication1\webform1.aspx.cs 行: 30