Archive for the ‘Tutorials’ Category

Find Regular Expression for words that contain only letters?

April 24, 2010 Leave a comment


Return words that only contain letters a-z and A-Z.


Return True or False if there’s a match.

Source Code (in C#)

static bool IsAllLetters ( string input )


Regex rg = new
Regex ( @”^[a-zA-Z]+$” );

return rg.IsMatch ( input );


Notes/Analysis of Source Code

The regular expression pattern contains: “^[a-zA-Z]+$”.

  • “^” matches the word from the beginning of the word.
  • “[a-zA-Z]” character class matches letters a – z and A – Z of the alphabets.
  • “+” quantifier
    matches 1 or more characters in the character class enclosed in the square brackets.
  • “$” matches the word to the end of the word.

Test Code (in C#)

static void TestIsAllLetters()


string[] words = { “.”, “a.b”, “the”, “dog”, “cat”, “!”, “1foo”, “foo2”,

“123foo”, “*gs.dogs” };

foreach ( string word in words )


Console.WriteLine ( string.Format ( “Does \”{0}\” contain all letters? {1}”, word,

IsAllLetters ( word ) ? “Yes” : “No” ) );




Getting started with Windows Azure

March 26, 2010 Leave a comment

I got the idea of blogging about Windows Azure and Cloud Computing from a Microsoft MSDN Event I attended in Seattle, Washington in March 2010. It was titled Cloud Computing and Azure. I have since gotten hooked after the event to see where I can learn a thing or two about cloud computing and Azure. In my quest to learn, I’ve decided to blog my encounter with the exciting technology by trying it out under the program Try Windows Azure in March and Win a Notebook. My aim here is not to win a notebook (still great if I win!) but to experience it from a developer/user’s perspective.


WARNING: Windows/SQL Azure is a paid-for service. You will need your credit card to register and deploy your application to the cloud.

I signed up for a trial offer using my credit card here with the Windows Azure Platform Introductory Special. This offer will allow me to try the Windows Azure platform at no charge which includes a subscription of:

  • 25 hours of compute hours
  • Windows Azure with 500 MB of storage. Windows Azure is the operating system as an online service.
  • SQL Azure – 1 Web Edition database. SQL Azure is simply a cloud database.
  • AppFabric – allows connection for cloud services and on-site applications.
  • Access control transactions and service bus.

Note: The offer ends July 31, 2010. After then, the standard rates will apply.


  1. Close Visual Studio if you have it opened.
  2. Download and install Windows Azure for Microsoft Visual Studio from here. This includes the Windows Azure SDK.
  3. You can go ahead and start both Development Fabric and Development Storage from Start | All Programs | Windows Azure SDK v1.0.
  4. Create yourself a new project from Visual Studio by clicking File | New | Project.
  5. Notice there is a new section called Cloud Service under Visual C# or Visual Basic. Click on Cloud Service and click Windows Azure Cloud Service. Enter a name for your cloud project and click OK.

  6. The “New Cloud Service Project” window will come up as below:

    Add “ASP.NET Web Role” and you can rename the title by highlighting the item on the right frame. Go ahead and rename it to “AzureWebRole”.

  7. After you click OK, open up Solution Explorer and notice the headings “AzureWebRole” and “CloudService1”. AzureWebRole is your usual ASP.NET web project and the additional project is CloudService1. This differentiates it from the normal ASP.NET web application and makes the project a Windows Azure cloud application.
  8. Now, create a new project from
    and sign in.
  9. Click on a project
    under Project Name.
  10. Click New Service.
  11. You will have two options but for the sake of this article, click Hosted Services:

  12. Enter a service name and description.
  13. Enter a public service name, check for availability and choose the appropriate region as below:

  14. After you have successfully created the service, you will get a screen as shown below:

  15. Now go back to the cloud service project you created in Visual Studio and right-click CloudServices1 and click Publish. A window will popup as below:

Copy the path to the location circled from the address bar and dismiss the window.

16. Now go to the Windows Azure web page and click Deploy as shown below:

17.  Click Browse under “Application Package”. Paste the path you copied previously and select “CloudService1”. You could tell this is the right file by making sure the type says “Service Package file”.

18.  Now, click Browse under “Configuration Settings”. This time select “ServiceConfiguration”.

19.  Once the deployment is done, you will see a screen as shown below. Make sure you understand the content of the page to avoid unnecessary charges to your credit card!Be sure to click Run. This might take a few moments. This action will enable, initialize and get your deployment ready for production. You will see the update below when your deployment becomes live:

That’s it; you can now click on your live cloud application under Web Site URL to go to your application on the cloud.

Clean up

Be sure to delete your service if you do not want to get charged on your credit card or if you do not wish to continue use of the service. Delete by clicking Suspend and click Delete afterwards.

Make sure you get a screen similar to the one below. Then you could be sure you would not continue to incur charges.

To be double sure you DO NOT get charged, you can go ahead and delete the service completely by clicking Delete Service:


Go ahead and have fun with Cloud Computing and Azure technologies!

Could not open a connection to SQL Server 2008 Express

March 25, 2010 Leave a comment

If you are working with Visual Studio Express 2008 or even trying to connect to a SQL Server Express data source and you see the error below, then this guide is for you.

Please follow the steps below to solve the problem:

  1. Click Start, click Run, in the Open box, type SQLServerManager10.msc, and then click OK to open the SQL Server Configuration Manager program.
  2. Click SQL Server Services and on the left window, right-click SQL Server Browser on the right window
    and click Properties. Click the Service tab and change the Start Mode to Automatic:

  3. Click the Log On tab and click Start to start the SQL Server Browser Service.
  4. Press OK to dismiss the properties window.
  5. Now go to the left window and expand SQL Server Network Configuration, click on Protocols for SQLEXPRESS. Right-click on TCP/IP on the right window
    and click Enable.
  6. You will get the following message, click OK.

  7. Click SQL Server Services on the left window, right-click on SQL Server (SQLEXPRESS) on the right window
    and press Restart.

Once the service has restarted, you should be able to connect to your SQL Server 2008 Express remotely. Have fun with it!

Getting started with Microsoft HealthVault

March 23, 2010 1 comment
  1. Download and install the Microsoft HealthVault SDK from
  2. Install the SDK and make sure you launch the Application Manager as shown below after the installation:

  3. Create an “Hello World” sample application by clicking on “Create New HelloWorld Sample”:

4. After you have created the “Hello World” application, it will open the project using Visual Studio. If you open up your solution explorer, you will see a window similar to the one below:

As you could see, you have the libraries already added for you so you can start getting productive with Microsoft HealthVault. You also have a default and master aspx pages. The “Redirect.aspx” will redirect you to your HealthVault account that you can use to logon. You can use OpenID or Windows Live ID. The page is as shown below:

5. After you’ve successfully logged in, HealthVault’s website will request for your permission for the application (e.g. HelloWorld-SDK) to use the information for the selected user.

6. The final stage of the permission process is to allow HealthVault access to read, update, create and delete information as shown below:

7. Once you click accept, HealthVault redirects you to your application (in this case HelloWorld-SDK).

8. You now have a functional web application that is integrated with Microsoft HealthVault.

Finally, happy coding with Microsoft HealthVault!