4
votes

So I am moving a DNN7 website from my local computer (the site has been developed in WebMatrix) to a Server running Windows Server 2008.

When I run the site I get the error. 'DNN Error Connection To The Database Failed'.

Now the strange thing is I downloaded Webmatrix on the 2008 Server and got the site to run fine, but running from IIS it does not work.

Why would it work for Webmatrix but not IIS?

Edit: My connection string is:

<add name="SiteSqlServer" connectionString="Server=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|Database.mdf;Database=DNN2;Trusted_Connection=Yes;" providerName="System.Data.SqlClient" />

Any thoughts why this connection string wont work?

I keep getting 'Connection to the database failed.

Thanks

James

1
Are you using Integrated Security when connecting to your database? If so, then when hosting it in IIS it will use the Application pools identity to connect to the SQL server. Create a sql user and then change your web.config to use a user id; password when connecting to your DNN Database. - Ryan Gunn
Does it matter that I am using SQL Express? I tried adding the user I created for the app pool but no change. - James Michael Lucas
It's shouldn't matter if you are using SQL Express. - Ryan Gunn
Adding a user and password does not seem to have changed anything. Does the connection string have any anomalies? - James Michael Lucas
You have integrated security set to True, that won't allow the username/password to work, that'll use the application pool - Chris Hammond

1 Answers

3
votes

Please make sure you update both SiteSqlServer settings in your web.config. Look below to see an example. One is under <connectionStrings> and the other under <appSettings>

      <connectionStrings>
        <add name="SiteSqlServer" connectionString="Server=myServerName;Database=myDataBase;User Id=myUsername;
Password=myPassword;" providerName="System.Data.SqlClient" />
      </connectionStrings>

      <appSettings>
        <add key="SiteSqlServer" value="Server=myServerName;Database=myDataBase;User Id=myUsername;Password=myPassword;" />
      </appSettings>

Hope this helps