Webpart SqlException Error Visual Studio 2010

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)

Solution:

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 :

Reff: http://forums.asp.net/t/1355323.aspx

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

For me:
2.1 Visual Studio 2010 Webpart SqlException Error

For anyone:
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.

2.2 Visual Studio 2010 Webpart SqlException Error

3. Membership / Role Provider Settings

For me: Add the following code in web.config file:

3.1 Visual Studio 2010 Webpart SqlException Error

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.

3.2 Visual Studio 2010 Webpart SqlException Error

 

4. Done

Reference:
1. http://forums.asp.net/t/1400394.aspx
2. http://www.studiocoast.com.au/knowledgebase/article-6-aspnet-using-sql-server-instead-of-aspnetdbmdf.aspx
3. http://forums.asp.net/t/1355323.aspx

Advertisements
By simplemsexchange Posted in ASP.NET

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s