ASP.NET MVC 3 Web Application Project Template

ASP.NET MVC 3 is a framework for building scalable, standards-based web applications using well-established design patterns and the power of ASP.NET and the .NET Framework.

However only the MVC 2 Web Application Project Template is available with Visual Web Developer 2010 Express initially and you have to download MVC 3 from following link and install it in order to get ASP.NET MVC 3 Web Application Project Template on VS Express.


Getting Started with WatiN

Here’s a code snippet to start testing with WatiN. Got it from the WatiN web site.

using System;
using WatiN.Core;

  class WatiNConsoleExample
    static void Main(string[] args)
      // Open a new Internet Explorer window and
      // goto the google website.
      IE ie = new IE(;
      // Find the search text field and type Watin in it.
      // Click the Google search button.
      ie.Button(Find.ByValue(“Google Search”)).Click();
      // Uncomment the following line if you want to close
      // Internet Explorer and the console window immediately.

Create Log file and attach Data file in SQL Server

You can attach a SQL Server data file(.mdf) which has no log file(.ldf) associate with the data file.

Use the following SQL Query with the correct path of the data file. 

ON (FILENAME = ‘C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\MyDB_Data.mdf’)  — change the drive and file path


Silverlight 4 Tools for Microsoft Visual Web Developer 2010 Express

The basic Microsoft Visual Web Developer 2010 Express does not contain Silverlight 4 tools and following is an update to Microsoft Visual Web Developer 2010 Express is required to support the targeted version of Silverlight.

Download the Visual Studio update at:

Know the version of Silverlight you have installed

Silverlight runtime needed for run silverlight enabled websites.

Silverlight developer.exe need to be installed for creating new project on silverlight in visual web developer 2010

check ur silverlight installation version from

Access to a SQL Server in some other Domain from SQL Server Management Studio

Senario in brief: My normal working domain is DomainA. But i have to connect to a sql server in DomainB. Administrators have given me remote desktop connection to the server which has sql server in DomainB but not to direct access from my SQL Server management studio.

Following is the solution.

runas /netonly /user:DomainB\sqladmin “C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe”

paste this infront of your command prompt and give the password for sqladmin user in SqlServer.
find the correct “Ssms.exe” path in your PC as “C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe” is in my PC.

SQL Server function to get Business Unit Guid by Name

This will be very useful when you are migrating data to CRM database from some other system database. Specially when filling base tables we should give business unit guid to it.
You can use following function and I have given the way that you should use it in your data migration scripts.
CREATE FUNCTION dmfx_GetBusinessUnit
    @businessUnitName nvarchar(30)
    SELECT [BusinessUnitId] AS BusinessUnit
    FROM [TEST_MSCRM].[dbo].[BusinessUnitBase]
    WHERE Name=@businessUnitName
Use\Invoke the above function as follows…

INSERT INTO [TEST_MSCRM].[dbo].[TEST_regionBase]
     [GUID] as TEST_regionId]
      ,GETDATE() AS [Created]
      ,(SELECT DataMigrationUser FROM dmfx_GetDataMigrationUserId()) AS [CreatedBy]    —    Data Migration User
      ,GETDATE() AS [Modified]                           
      ,(SELECT DataMigrationUser FROM dmfx_GetDataMigrationUserId()) AS [ModifiedBy]    —    Data Migration User
      ,(SELECT DataMigrationUser FROM dmfx_GetDataMigrationUserId()) AS [OwningUser]    —    Data Migration User
      ,(SELECT BusinessUnit AS [OwningBusinessUnit] FROM dmfx_GetBusinessUnit(‘TESTBUSINESSUNIT’)) AS BusinessUnit     —   
      ,0 AS [statecode]
      ,1 AS [statuscode]
      ,0 AS [DeletionStateCode]
      ,null AS [ImportSequenceNumber]
      ,null AS [OverriddenCreatedOn]
      ,0 AS [TimeZoneRuleVersionNumber]
      ,null AS [UTCConversionTimeZoneCode]

FROM [EXISTINGDB].[dbo].[ClientRegions]

Set CRM Date Field to Empty

I have a check box and a date field on the form. The requirement is to display the System Date in the date field when the check box is checked by the user and to clear the date field when the check box is unchecked by the user. Although the user has unchecked the check box and saved the form it displays the previously saved date by the user. I used the following code to save it.

Following code will solve the problem and will set it to Empty when it saved.

      //get the value of Reviewed by Manager checkbox
    var ReviewedManager = crmForm.all.cpms_reviewedbymanager.DataValue;

    //if Reviewed by Manager chekbox is checked
    if (ReviewedManager == true)
        //set the Date Reviewed by  to system date
        crmForm.all.cpms_datereviewedbymanager.Disabled = false;
        crmForm.all.cpms_datereviewedbymanager.DataValue = new Date();
        crmForm.all.cpms_datereviewedbymanager.DataValue = null;
        crmForm.all.cpms_datereviewedbymanager.ForceSubmit = true;
        crmForm.all.cpms_datereviewedbymanager.Disabled = true;