While I am using Visual studio 2010, it gives me pain of 3 days to use webpart in webpage. Whenever I want to use webpart, the following error comes:
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)
WebPart personalization uses ASPNETDB.mdf to store the personlized data. Before using WebParts, you will need to install & configuration database.
You may not willing to use a local database like ASPNEDDB.mdf (For example, I dont want to use it). Using SQL Server instead of ASPNETDB.mdf :
1. Setting up the database to work with ASP.NET
Open (Just double click) aspnet_regsql.exe from: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_regsql.exe
Please Check the snapshots aspnet_regsql
2. Modifying the web.config to support the new membership provider
2.1 Visual Studio 2010 Webpart SqlException Error
Setup the connection string in your web.config file something like below.
Remember to change the SQL_SERVER_ADDRESS, DATABASE_NAME, SQL_USERNAME, SQL_PASSWORD to the details you were given.
3. Membership / Role Provider Settings
For me: Add the following code in web.config file:
For anyone else:
Add the following sections within the section of the configuration.
Note the “connectionStringName” if you use one different to the one above.
The roleManager section below can be left out if you do not use roles on the site.