Click here to Skip to main content
12,406,795 members (61,626 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

5.9K views
3 bookmarked
Posted

SQL Express Membership API Provider Utility

, 15 Jul 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
SQL Server Express Membership API Provider Utility

Introduction

This article discusses the building of a Visual Basic .NET console
application for adding the Membership API database schema to a SQL Server
Express database created within Visual Studio.  The console application
prompts the user for the full path and filename with extension for a SQL Server
Express database file.  The user can enter the filename manually, or click
on the icon to paste the text via the menu.  When the user presses enter,
the database is updated with the Membership API database schema.  Once the
console application has finished running, prompts the user to press any key
before exiting.  This way, the user gets a chance to see any error messages
in case anything goes wrong.

The main code that makes all this possible is:

' Install the Membership API Provider tables, views, and stored procedures into the user's database.
System.Web.Management.SqlServices.Install(databaseName, SqlFeatures.All, connectionString)

Note: The database name is the full path, filename, and file extension.

The screenshot below shows what the finished tool looks like.

SQL Express Membership Provider Utility

Background

When I create a database within an ASP.NET application's App_Data folder, I
cannot use the aspnet_regsql utility to insert the tables, views, and stored
procedures associated with the Membership API. The only way to do this is to
detach the database from Visual Studio, attach the database to SQL Server
Management Studio, run the aspnet_regsql utility, detach the database from SQL
Server Management Studio, and reattach the database to Visual Studio.

Using the Code

To use this code create a Visual Basic .NET console application, and add the
SQLExpress.vb
module displayed below.  Then you can compile and run the tool.  A
project is included for you to load up into Visual Studio 2008.

' ================================================================================================================
' Mondule Name       : SQLExpress.vb
' Module Description : Accepts the filename for a SQL Server database file, and creates the Membership API
'                    : provider tables, views, and stored procedures in that database.
' Author             : Jason W. Alls
' License            : Use of this software is subject to your acceptance of the The Code Project Open License 
'                    : (CPOL) 1.02 included with this project.
' Date Created       : 11th July 2010, 21:27
' ================================================================================================================
Imports System.Data.SqlClient   ' Needed for the database connection.
Imports System.Web.Management   ' Needed to add the Membership API Provider Schema to the user's database.
 
''' <summary>
''' Accepts the filename for a SQL Server database file, and creates the Membership API
''' provider tables, views, and stored procedures in that database.
''' </summary>

Points of Interest

This application was developed as a quick and dirty solution to solve the
issue explained above in the background section.  When you use this tool,
Visual Studio can be open with the database attached.  There is obviously
room for improvement. I believe the best way to improve this tool will be to
convert it to a Visual Studio add-in.  The add-in would add an 'Insert
Membership API schema' menu item to the database context menu.  Clicking
this option would then perform the database upgrade, and refresh the server
explorer window.

History

15th July 2010, 21:27 Initial Version (1.0.0) Build Completed.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

jasonalls
Software Developer Lucid Research Limited
United Kingdom United Kingdom
I have been programming software since 1999. My qualifications include CIW Associate, SCJP for the Java 1.4 Platform, MCAD using Visual C#, and PRINCE2 Practitioner.

You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.160730.1 | Last Updated 15 Jul 2010
Article Copyright 2010 by jasonalls
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid