ASP.NET Membership Using a Custom Profile

ASP.NET Membership Custom Profile

The ASP.NET Membership is an easy way to manage user credentials and security within ASP.NET Web Application (Web Site).  ASP.NET Membership will not only handle user authentication, it can also be used to manage user profile information.  To add a Custom Profile for the ASP.NET Membership users you need to enable profiles, specify a profile provider and add the profile properties in the system.web section of the web.config file:
<profile enabled="true">
				<remove name="AspNetSqlProfileProvider"/>
				<add name="AspNetSqlProfileProvider" connectionStringName="SqlMembership" applicationName="appProfile" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
				<add name="Gender" type="System.String"/>
				<add name="favoritenumber" type="System.Int32"/>
				<add name="notification" type="System.Boolean"/>
				<add name="BirthDate" type="System.DateTime"/>
Once the profile information has been enable and configured a user’s profile information can be read and saved through the dynamic ProfileCommon class. The ProfileCommon class will the properties specified in the configuration file.  A simplified code example for reading and saving profile values:
protected void Page_Load(object sender, EventArgs e)
        if (!IsPostBack)
            if (User.Identity.IsAuthenticated == true)
                MembershipUser user = Membership.GetUser();
                ((TextBox)LoginView1.FindControl("Email")).Text = ((TextBox)LoginView1.FindControl("Email2")).Text = user.Email;
                ((TextBox)LoginView1.FindControl("txtNumber")).Text = Profile.favoritenumber.ToString();
                DropDownList ddl = (DropDownList)LoginView1.FindControl("ddlGender");
                ddl.SelectedIndex = ddl.Items.IndexOf(ddl.Items.FindByValue(Profile.Gender));
                ((CheckBox)LoginView1.FindControl("chkNotification")).Checked = Profile.notification;

    protected void btnSave_Click(object sender, EventArgs e)
        if (Page.IsValid)
            TextBox Email;
            MembershipUser user = Membership.GetUser();
            Email = (TextBox)LoginView1.FindControl("Email");
            if (user.Email != Email.Text)
                user.Email = Email.Text;
            Profile.Gender = ((DropDownList)LoginView1.FindControl("ddlGender")).SelectedValue;
            Profile.notification = ((CheckBox)LoginView1.FindControl("chkNotification")).Checked;
            Profile.favoritenumber = System.Convert.ToInt32(((TextBox)LoginView1.FindControl("txtNumber")).Text);

ASP.NET Membership Custom Profile

SQL: Set a database to Single_User Mode

There are instances when a database administrator may need to set a database to single user mode. The database access can be set through SSMS (SQL Server Management Studio) and through the use of SQL commands.

To set the database access to single user mode using SSMS (SQL Server Management Studio):

  1. Open SSMS
  2. Right click on the Database that is to be set to SINGLE_USER mode and click Properties
  3. Scroll down to the State section of the Database Properties window
  4. Set the Restrict Access property to SINGLE_USER
  5. Click OK to close the Database Properties window


The above steps can be also used to set the database back to MULTI_USER mode by choosing the MULTI_USER option in step 4.


To set the database access to single user mode using SQL commands you can either use the ALTER DATABASE command or the sp_dboption stored procedure:

-- Set a database to single user mode

-- set a database to multi user mode

-- Set a database to single user mode
EXEC sp_dboption '<database name>', 'single user', 'true'

-- set a database to multi user mode
EXEC sp_dboption '<database name>', 'single user', 'false'

Note: replace with the name of the database to be affected

Chrome OS Test Drive

Chrome OS

I use Parallels on the Mac to facilitate the use and testing of various operating systems. Parallels has built into it the option (File-Download Chrome OS from the main menu) for creating a Chrome OS virtual machine. I downloaded the pre-built Chrome virtual machine and gave it a test drive. Don’t get me wrong; I am huge Google fan, but y initial thoughts left me unimpressed. Chrome is basically Google on a device. I understand the intention of the OS on a netbook or mobile device, however I think when compared to other such operating systems Chrome has a bit of maturing to do.

BlogEngine.Net: +1 (plusone) Button

There has been a lot of discussion lately about Google’s +1 service. Google has even made it easy to add a +1 button to your webpage.

It is just as easy to add a +1 button to your BlogEngine.Net posts.

First need to add the following script to the HEAD section of your site.master template.


<script type="text/javascript" src=""></script>


Then you only need to add the following to your PostView.ascx file where you would like the button to be displayed:


<g:plusone size="small" count="false" href="<%=Post.PermaLink %>"></g:plusone>

To display the +1 count for the post change the count attribute to true.


You can see more +1 button options here.

Microsoft Dynamics Nav: SQL Update Posting Date Range for All Companies

This is a SQL script that changes the posting date range for all companies in a Microsoft Dynamics Nav "database".  This script can be scheduled with a job to automate the task.  This script sets the General Ledger Setup posting date range for all companies to the current day (one day). This script can be easily modified to allow for a date range of more than one day.

declare @cmd as varchar(max)
declare @tablename as sysname
declare @ds as varchar(20)
declare @pd as date
set @pd = GETDATE()
SELECT @ds = LEFT(CONVERT(VARCHAR, @pd, 110), 10)

-- Declare a cursor.
declare tablenames insensitive scroll cursor
	select [name] from sys.sysobjects where (xtype = N'U') and ([name] like N'%General Ledger Setup')

-- Open the cursor.
open tablenames

-- Loop through
while (1=1)
		fetch next from tablenames into @tablename;
		if @@fetch_status <> 0 break;		
		set @cmd = 'update [' + @tablename + '] SET [Allow Posting From] = ''' + @ds+ ''', [Allow Posting To] =''' + @ds + '''' 
		exec (@cmd)
		print @cmd;

-- Close cursor		
close tablenames;
deallocate tablenames;

-- #####

Reading Stuff

Information in this document subject to change without notice.
All Software source code published is for demonstration and knowledge sharing purposes only. The Code is supplied "as is" without warranty as to result, performance or merchantability. Use at your own risk.
The opinions expressed herein are the opinions of the author and do not reflect those of any other entity.