I have a small ASP.NET 2.0 that uses an instanse of SQLExpress. The connection string looks like this:
<connectionStrings>
<add name="DatabaseConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
It works fine when I use it in file system. When I copy it to the server ( IIS6 on Windows Server ) it gives me an error:
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
I tried changing the path to the local path on the server but it did not help.
Any help would be greatly appreciated.
With the way that you have the connection string configured you are using a user instance. What you sould do is make sure that sql express is installed on the server. Configure your web application directories and then install your application. On the server inside your web directories you should hava folder called app_data (The same as your local machine). Next I would perform an IISRESET once the app is loaded and the start the application up. You might find that the first time the app might time out on the database... just restart the browser session and it should fire up. You do not need to move the database to a different directory on the server as the connection string uses the datadirectory with is the app_data directory from your web solutions.
No comments:
Post a Comment