Anup Shah on WPF and Silverlight (Programming Garden)

IT 's For You!!!

Thursday, November 8, 2012

Create ASPNETDB database using aspnet_regsql tool


What is ASPNETDB?

Microsoft has introduced a powerful default database schema in ASP.Net 2.0 as ASPNETDB.mdf database. This database file serves as a role provider, membership provider and web parts personalization handling with the help of BLOBs.

Microso Visual Studio supports the ASP.Net configuration to manage this personal ASPNETDB database file within the web application inside the App_Data folder.

Uses of ASPNETDB database: 

ASPNETDB database helps in managing users along with their roles e.g. admin, employee, editors, etc.
It also enables the in-built functionality of Login controls and web parts to be integrated on ASP.Net web pages that helps in managing user profiles, login, and personalized user pages very easily even without writing the bulky code to implement the SQL queries or stored procedures along with data access code for inserting, updating or deleting the user personalized data.


How to use ASPNETDB database?

Fist you need to merge ASPNETDB with your own database. You can merge both databases using tool called "aspnet_regsql".

You can use aspnet_regsql command to create ASPNETDB database. This command executes the default scripts to create the default database for ASP.Net web applications.

Steps to create ASPNETDB database using aspnet_regsql tool:  

Open the Visual Studio command prompt from Start -> All Programs -> Microsoft Visual Studio 2005 -> Visual Studio Tools -> Visual Studio 2005 Command Prompt
Type aspnet_regsql and press enter key. This will open the ASP.Net SQL Server Setup Wizard. Click next to continue…
In the next dialog box, select the option "Configure SQL Server for application services". This option executes a script to configure the database for managing user profiles, roles, membership and personalization. Click next to continue…
In this step enter the SQL server name and choose the right authentication method. Leave the database field to default and click next…
Confirm your settings and click next to finish

OR 

 1. Open the command line by opening the Run dialog box and enter cmd. Then change to the directory C:\Windows\Microsoft.NET\Framework\v2.0.50727
[Note that the last directory’s name may be different, just make sure it’s v2.0, which signifies version 2.0 of the .NET Framework]
 2.  In this directory run the executable called aspnet_regsql.exe
 3. Follow the wizard provide Server Name and the Database Finish it.

OR 

Go Through my post simple way.
http://anupshah-wpfandsilverlight.blogspot.in/2012/11/how-to-create-aspnetdb-database.html


To let the solution use the database for user access and profiles, a hidden connection string called LocalSqlServer has to be removed and added again with the new settings. The following code example does that.

 <connectionStrings>
        <!-- Previously defined connection strings will be here -->      
        <!-- LocalSqlServer is the connectionstring used by the asp.net -->
        <!-- access and profile modules -->
        <remove name="LocalSqlServer"></remove>
        <add name="LocalSqlServer"
            connectionString="Data Source=anupDB2005;
                              Initial Catalog=ExperimentalDB;
                              User ID=anup;
                              Password=anup1"
            providerName="System.Data.SqlClient">
        </add>
    </connectionStrings>

Once you merge both databases using above steps, you need to upload them in live server.

Happy Coding...:)
Hope it can be helpful for you!

Thanks & Regards,
www.galaxywebmind.com
, , ,

4 comments:

  1. hi please how do I find the visual studio 2012 command prompt , I can't seems to locate it.

    ReplyDelete
    Replies
    1. you can use the following path keep in mind i am using Win8 x64 you path might be different: C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC

      Delete
  2. Thanks for sharing the blog regarding the database. We are also All india database provider

    ReplyDelete