Skip to main content

Posts

Showing posts from June, 2012

String.ToTitleCase() extension method to convert String to Title Case or Pascal Case

As you most of you already aware, there are ToLower() and ToUp­per() meth­ods available for String class in C#, but there is no method to con­vert a string to ‘ Title Case ’. We can implement this conversion with the help of Tex­tInfo class which has a ToTi­tle­Case method, but you can’t create a new instance of the Tex­tInfo type as there is no pub­lic con­struc­tor available. Instead you will need to first cre­ate a new CultureInfo object. To create a new CultureInfo object you can either use hard-coded culture or you can  use the cur­rent cul­ture of the exe­cut­ing thread as:             var cultureInfo = System.Threading. Thread .CurrentThread.CurrentCulture; That way, if you don’t care about the cul­ture info you’re using, you will just default to what­ever cul­ture info your cur­rent thread is using, much cleaner than the alternative! Here I'm writing extension method of String  named ToTitleCase , in class StringExtension, I have created three extension m

SQL SERVER – Database diagram support objects cannot be installed because this database does not have a valid owner

This is one of the common error message developer face while creating DB diagram. Error Screen: Solution : Solution is simple one, run following script to  ALTER AUTHORIZATION for your DB. -- Replace DB_Name : to your DB ALTER AUTHORIZATION ON  DATABASE::DB_Name  TO  sa GO Or you can Alter Authorization with designer with following steps: Right Click on your DB and Select Properties Select Files (second option from left side pane). In the OWNER box, click on button to add user(reference: below fig.). Now select user ‘sa’ and click OK.

Add/Create ASP.NET Membership tables/view/sp with aspnet_regsql

To install the membership database, log on to your server with an account that has authority to administrate SQL Server (such as the Administrator account). If you want to add membership tables to existing DB then use that DB in example else create new DB, here I’m creating new DB with Name Test_Membership as below(and will use this DB throughout this example):   Fig.1 Create New DB wizard   Fig.2 Give DB name and click OK to create DB Now DB is created, next step is create Membership tables to your DB, here we goes: If you love to work with command prompt then follow these two simple steps: 1. Start a Visual Studio command prompt by going to Start -> All Programs -> Visual Studio 2010 -> Visual Studio Tools -> Visual Studio Command Prompt. 2.  Run the following command, using the your Test_Membership database settings to fill in the values in brackets: aspnet_regsql.exe -S [Host] -d [Name] -U [Username] -P [Password] -A all And your Members