Wednesday, December 18, 2013

Connect ASPNETDB withVisual Studio

While configuring Web Site Administration Tool if you have encounters the following errors than you are at the right place 
  • There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.
  • The following message may help in diagnosing the problem: Unable to connect to SQL Server database.

Provider Management

Could not establish a connection to the database.
If you have not yet created the SQL Server database, exit the Web Site Administration tool, use the aspnet_regsql command-line utility to create and configure the database, and then return to this tool to set the provider.
 

Solving this issue is quite simple, just follow the simple steps

1. Fist run the utility aspnet_regsql.exe to create your ASPNETDB

Now in order to connect to this DB within your visual studio

2. Inside Visual studio open up your project web.config file

3. Add the following lines inside <configuration> tag 

<connectionStrings>

    <remove name="LocalSqlServer"/>
    <add name="LocalSqlServer" connectionString="data source=.;DataBase=aspnetdb; Integrated security=true;"/>


  </connectionStrings>


There are three things in this connection string
  • data source (If your database is present on the machine on which you are working than leave it as it is)
  • DataBase (If you have explicitly changed your DataBase name than change aspnetdb with your DataBase Name)
  • integrated security (If you are using windows authentication than leave it as it is)
4. Save and Built

That's it now start ASP.NET Configuration(WSAT) and it should work properly this time

I hope it was informative for you and I would like to Thank you for reading

No comments:

Post a Comment