Config IIS Express with SSL

<site name="WebPortal" id="2">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
            <virtualDirectory path="/" physicalPath="C:\WebPortal\Dev\POC\WebPortal\WebPortal.Main" />
            <binding protocol="http" bindingInformation="*:3303:localhost" />
            <binding protocol="https" bindingInformation="*:44302:localhost" />


Error: exception has been thrown by the target of an invocation

This problem is cause by the System variable "Path" too long.


  1. Pressing 'Windows Key' + 'Pause Break'
  2. 'Advanced system settings' on the left
  3. 'Environment Variables' on the lower right corner
  4. Selecting 'PATH' under 'System variables'
  5. Clicking 'Edit'
  6. Shorten the path or setup another system variable to group some of the path

Insert into temporary table from Stored Procedure

DECLARE @mast_key_table table
    mast_key int,
    inc_mmk_calculation int,
    lastest_trx_date datetime null,
    ast_key int,
    pln_key int,
    sp_key int,
    seg_key int,
    incdet_key int,
    incdet_effdate datetime,
    uv_value decimal (18,8),
    incdet_cutoffdate datetime
-- EXEC sp_get_mastfordailyincdist <task_key>
INSERT INTO @mast_key_table
EXEC sp_get_mastfordailyincdist 4158
SELECT * from @mast_key_table order BY lastest_trx_date

SQL - Index node value in XML column


The below is from MSDN

Caution noteCaution

The default ARITHABORT setting for SQL Server Management Studio is ON. Client applications setting ARITHABORT to OFF can receive different query plans making it difficult to troubleshoot poorly performing queries. That is, the same query can execute fast in management studio but slow in the application. When troubleshooting queries with Management Studio always match the client ARITHABORT setting.


"SET ARITHABORT must be ON when you are creating or changing indexes on computed columns or indexed views. If SET ARITHABORT is OFF, CREATE, UPDATE, INSERT, and DELETE statements on tables with indexes on computed columns or indexed views will fail."

SQL SERVER – Compatibility level

SQL SERVER – Fix : Error : Incorrect syntax near . You may need to set the compatibility level of the current database to a higher value to enable this feature. See help for the stored procedure sp_dbcmptlevel




Change the database compatibility level using following command in management studio.

For SQL Server 2005:
EXEC sp_dbcmptlevel 'DatabaseName', 90

For SQL Server 2008:
EXEC sp_dbcmptlevel 'DatabaseName', 100

Validate DateTime

public static bool ValidateDateFormat(string sDate)
     bool isValid = true;
     DateTime Test;
     string[] formats = { "MM/dd/yyyy""M/d/yyyy""M/dd/yyyy""MM/d/yyyy" };
     if (!DateTime.TryParseExact(sDate, formats, new CultureInfo("en-US"), 
DateTimeStyles.None, out Test))      {         isValid = false;      }      //      return isValid; } public static DateTime ConvertDate(string sDate) {   string[] formats = { "M/d/yyyy""MM/dd/yyyy""M/dd/yyyy""MM/d/yyyy" };   DateTime tDate;   DateTime.TryParseExact(sDate, formats, new CultureInfo("en-US"),
DateTimeStyles.None, out tDate);   return tDate; }

SSIS - generate deployment manifest file

Creating a Deployment Manifest

  • With the Solution Explorer open Right-Click on the project name and click Properties
  • This will open the Project Properties Pages
  • Select the Deployment Utilityfrom the page
  • Change the CreateDeploymentUtility property to True

After you’ve gone through these steps the next time you build your project it will create the file (YourProjectName).SSISDeploymentManifest. This file is located in the same folder as your packages in the bin\Deployment folder.

If you run this file it will open the Package Installation Wizard that will allow you to deploy all your packages that were located in the project to a desired location.

jquery checkbox

To check on/off a checkbox:

To check if checkbox check on:

e.Row.RowState == DataControlRowState.Edit not works on Alternating Rows


The combine Alternatiing/Edit state fail the comparsion logic.


if ((e.Row.RowState & DataControlRowState.Edit) > 0)

Attach already changed object to a data context


Using one data context for selecting data and another for submitting the changes made. The problem is that once you  attach an object to the new context you'll lose tracking of all changes made to the object.

All changes will lost after you save change.


Call the SetModifiedProperty method  to notify the ObjectStateManager of the data context about the changes.


AdventureWorksLTEntities context = new AdventureWorksLTEntities();
            Product product = context.ProductSet.FirstOrDefault();
            if (product != null)
                product.ListPrice += 10; // product.EntityState is set to Modified

            AdventureWorksLTEntities newContext = new AdventureWorksLTEntities();

            context.Detach(product); // product.EntityState is set to Detached
            newContext.Attach(product);  // product.EntityState is set to Unchanged

            ObjectStateEntry state = newContext.ObjectStateManager.GetObjectStateEntry(product);
            state.SetModifiedProperty("ListPrice"); // product.EntityState is set to Modified