To prevent Visual Studio from using SQLEXPRESS when using Webparts and WebPartManger, you will need to override the "LocalSqlServer" connection string from your machine.config into your web.config file. To do that, add the following to the <connectionstrings> sections in your webconfig file:
<remove name="LocalSqlServer"> <add connectionstring="data source=.\YOURINSTANCENAME;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" name="LocalSqlServer" providername="System.Data.SqlClient"> </add>
Othwerise, if you do not have an instance named SQLEXPRESS in your machine, the page containing your WebPartManager will fail with the following error:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Comments