Language

Table Profile Provider Samples

The default SqlProfileProvider that ships with ASP.NET 2.0 “blobicizes” Profile data using string, XML or binary serialization prior to storing information in SQL Server. A frequent request from developers is the ability to store Profile data “in the clear” in the database so that the data is available for querying and use in stored procedures. The two samples in this download solve this problem.

Features

The first sample provider (SqlTableProfileProvider) stores each Profile property in a separate database column. Furthermore the provider stores the Profile data without serializing it, which means that the Profile property type needs to be compatible with the target database column.

The second sample provider (SqlStoredProcedureProfileProvider) maps each Profile property to a parameter on a custom stored procedure. Like the table based provider, this provider expects that each Profile property is of a type that is compatible with its corresponding stored procedure parameter. The powerful aspect of the stored procedure based provider is that other than the requirement to implement some stored procedures with a specific set of parameters, you can implement whatever business logic you need in the stored procedures to map the Profile data to your own database schema and database logic.

Setup

The downloadable samples include walkthroughs for setting up and using both the table-based and the stored procedure based providers. To make use of the sample site:

  • Copy the files in this sample to a virtual directory.
  • Edit the web.config file to change the connection string so it points at your database and server.
  • In the App_Data directory there is a sample SQL script that you can use with the walkthrough document. You will need to change the database name and security accounts in the database script to match your database environment.

About the Author

Hao Kung Hao Kung is a Software Design Engineer working in the Microsoft ASP.NET team. He grew up in New Jersey, graduated from Cornell University in 2001, and joined Microsoft in 2003. He enjoys playing computer games, poker, and reading fantasy and sci-fi novels during his free time.