0
votes

I have an ASP.NET 4.0 website hosted on GoDaddy that has a database. My site will not coming up. I think it's my database connection -

My connection string -

  <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>

The error from my page -

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

Can anyone tell me if it is actually my connection string or something else? The website is located at - http://www.fonyfacts.com/ Thanks

2
Don't reveal your database info online - pad these attributes with dummy characters. - IrishChieftain
just debug your code and show us where exactly the error is caused - FosterZ

2 Answers

0
votes

You shouldn't override the LocalSqlServer connection string name. It's defined in the machine.config file and for some reason has a special meaning making it one of the only 2 names you can't use (LocalMySqlServer being the other, also defined in machine.config). Pick any other name for your connection string.

Also, you're missing the Data Source attribute in the connection strings but I'm sure this was from your masking step.

0
votes

I think you are passing some wrong values in connection string...

Server should be like

server=xpode.db.4563273.hostedresource.com

My site is also there ... and working with same connection. Please verify your db credentials

Thanks,
Rohit
xpode.com