2012-10-06 55 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? –