2012-10-06 56 views
0

我有一個ASP.NET 4.0網站託管在GoDaddy上有一個數據庫。我的網站不會出現。我認爲這是我的數據庫連接 -ASP.NET網站故障 - DataAccessLayer引發異常

我的連接字符串 -

<connectionStrings> 
    <add name="Personal" connectionString=" Server=xyz.com; Database=xyzDb; User ID=xyzUser; Password=xyzPass; Trusted_Connection=false" providerName="System.Data.SqlClient" /> 
    <remove name="LocalSqlServer"/> 
    <add name="LocalSqlServer" connectionString=" Server=abc.com; Database=abcDb; User ID=abcUser; Password=abcPass; Trusted_Connection=false" providerName="System.Data.SqlClient" /> 
    </connectionStrings> 

從我的頁面中的錯誤 -

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.] FonyFacts02.DataAccessLayer..ctor() +74
FonyFacts02.DataAccessLayer..cctor() +39

[TypeInitializationException: The type initializer for 'FonyFacts02.DataAccessLayer' threw an exception.]
FonyFacts02.DataAccessLayer.GetInstance() +0
FonyFacts02.FonyFacts..ctor() +34
FonyFacts02.Default.Page_Load(Object sender, EventArgs e) +99
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) +91
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207

誰能告訴我,如果它實際上是我的連接字符串或其他什麼東西? 該網站位於 - http://www.fonyfacts.com/ 謝謝

+0

不要在網上泄露了你的數據庫信息 - 墊這些屬性與虛擬人物。 – IrishChieftain

+0

只是調試你的代碼,並告訴我們究竟在哪裏造成的錯誤 – FosterZ

+0

感謝您的意見! –

回答

0

您不應該重寫LocalSqlServer連接字符串名稱。它在machine.config文件中定義,由於某些原因具有特殊含義,使其成爲您不能使用的唯一兩個名稱之一(另一個LocalMySqlServer,也在machine.config中定義)。爲連接字符串選擇其他名稱。

此外,您在連接字符串中缺少數據源屬性,但我確定這是來自您的屏蔽步驟。

+0

謝謝Draghon。你是說我需要刪除 - ''和'

+0

爲連接字符串使用不同的名稱。如果您選擇一個唯一的名稱,則不需要「刪除」行。 – Draghon

0

我想你傳遞一些錯誤的值在連接字符串...

服務器應該像

服務器= xpode.db.4563273.hostedresource.com

我的網站也有...並使用相同的連接。請驗證您的數據庫憑據

感謝,
羅希特
xpode.com

+0

謝謝Rohit! 我確實有**服務器= **部分。有人編輯我的文章,並意外地把它拿出來(他們不喜歡我在我的實際服務器名稱中)。你有兩個部分在你web.config做一個刪除和添加LocalSqlServer? –