This blog is moved to
http://amalhashim.wordpress.com

Wednesday, January 21, 2009

Try - Catch in Sql Server 2005

  • A TRY Block - the TRY block contains the code / script that might cause an exception

  • A CATCH Block - if an exception occurs from one of the statements in the TRY block, control is branched to the CATCH block, where the exception can be handled, logged, and so on.

BEGIN TRY

BEGIN TRANSACTION

stmts...

END TRAN

END TRY
BEGIN CATCH

IF @@TRANCOUNT > 0
ROLLBACK TRAN

END CATCH


Visual Studio 2008 Keyboard Shortcuts


Alt+Shift+Enter

Full Screen

Ctrl+M+M

Expand Collapse

Ctrl+K+D

Auto Indent the whole file

Ctrl+K+F

Auto Indent Selected

Ctrl+.

Resolve Namespace

Ctrl+K+C

Commenting Code

Ctrl+K+U

Uncommenting Code

prop+TAB+TAB

Auto generate property

Ctrl+Shift+B

Build solution

Shift+F5

Stop debugging

Alt+D+P

Attach process window

Ctrl+Shift+F

Find in files

F7

Switch between design and code view

Ctrl+Alt+L

Open solution explorer

F4

Open properties window

Ctrl+\+T

TaskList

Ctrl+\+E

ErrorList

Ctrl+-

Return back to the previous code

Friday, January 16, 2009

Creating a Google Search bookmarklet

javascript:Qr=document.getSelection();if(!Qr){void(Qr=prompt('Keyword...',''))};if(Qr)location.href='http://www.google.co.in/search?q='+escape(Qr)


copy the above script and save it as a link.

Visual Studio 2008 + Open Containing Folder

In Visual Studion 2008, Go to Tools->Options->Keyboard and select File.OpenContainingFolder

Assign a keyboard shortcut for this.


Done.

Saturday, January 10, 2009

New in C# 3.0 - Object Initializers

In normal scenario we used to create and initialize object as

Sample sample = new Sample();
sample.Value = "value";
sample.Text = "text";

In C# 3.0 the same can be achieved as

Sample sample = new Sample()
{ Value="value", Text="text" };

New in C# 3.0 - ?? Operator

The ?? Operator return the left hand operand if it is not null. Else it will return the right hand operand.

if(testObject == null)
{
testObject = new TestObject();
}

return testObject;

The above code can be represented in the following one liner

return testObject ?? new TestObject();

Free EBooks at CodePlex


There are many more books available. Go and grab them

· Acceptance Test Engineering Guidance

· Application Architecture Guidance

· Common Service Locator

· Composite Application Guidance for WPF

· Design for Operations

· Enterprise Library

· ESB Guidance

· GAX Extensions Library

· Guidance Explorer

· Performance Testing Guidance for Web Applications

· Performance Testing Guidance Project

· SharePoint Development Guidance

· Smart Client Guidance

· Team Development with Visual Studio Team Foundation Server

· Unity Application Block

· VSTS Guidance Project

· WCF Security Guidance

· Web Client Software Factory

· Web Service Software Factory

More http://msdn.microsoft.com/hi-in/practices/bb190344(en-us).aspx

Windows 7 Beta Released

The Windows 7 beta is available for download, but only for the first 2.5 million users, so act fast!!

Get yours now. Go to http://www.microsoft.com/windows7 for more info or download it here

Monday, January 5, 2009

Adding "Copy To/Move To" in Windows Context Menu

Start->Run

Enter the following command regedit and click Ok.

This will bring up the Windows Registry Editor.

From the left navigation tree navigate to the following location

HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers

Right Click "ContextMenuHandlers"

From the menu Select New->Key and type "Copy To Folder" and enter.
Now select Copy To Folder from left navigation
Double click default item from right hand pane and provide the following value

{C2FBB630-2971-11D1-A18C-00C04FD75D13}


Right Click "ContextMenuHandlers"

From the menu Select New->Key and type "Move To Folder" and enter.
Now select Copy To Folder from left navigation
Double click default item from right hand pane and provide the following value

{C2FBB631-2971-11D1-A18C-00C04FD75D13}


Done.