以下是我在運行SQL Server 2000的IIS v6.0服務器上訪問網站時遇到的錯誤,該網站由我託管。我從另一個位置移動了這臺服務器,所以我想知道它是否找不到數據庫。你有什麼建議?感謝對象無法引用實例對象錯誤 - IIS 6.0 SQL Server 2000
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 38: {
Line 39: ds = dbCat.Getcategories();
Line 40: DataRow dr = ds.Tables[0].NewRow();
Line 41: dr["id"] = "0";
Line 42: dr["name"] = "All";
Source File: c:\webapps\pbxc.new-web.09302009\PBXC_Updated_\Website\support.aspx.cs Line: 40
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
support.loadCategories() in c:\webapps\pbxc.new-web.09302009\PBXC_Updated_\Website\support.aspx.cs:40
support.Page_Load(Object sender, EventArgs e) in c:\webapps\pbxc.new-web.09302009\PBXC_Updated_\Website\support.aspx.cs:25
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053
添加以下代碼段,或者'ds'或'Tables'爲空。也許'dbCat.GetCategories()'沒有返回任何東西? – Tim