Monday, 23 September 2013

Question: How to remove white space from a number in excel?

Sometime we got the data in excel sheet in number format which contain space as 1000 separator. This format could cause the problem if you use those excel data further as number in data upload process. In data upload process SSIS package will not work because of set up rules. So at that time we need to remove black space between the numbers. For that follow the below steps -

Step 1 -  Copy the space only after select.
Step 2 - Use substitute method in excel as below screen shot -

Note : In the substitute method, space should be copied(ctrl +C).
I hope this will solve the problem.

Let me know here if anyone have better answer.

Sunday, 15 September 2013

Convert DataTable to List in c#

There is very simple way to convert a datatable into generic list in c#. Have a look at the below steps -

Step 1 - Get the datatable, In my example datatable in containing three columns. Those are Name, Designation and Department.

Step 2 - Add a public class to your solution (Right click and add new items then chose class) to define the properties for the list.

public class PropertyClass
    private string name;
    public string Name
        get{return name;}
        set { name = value; }

    private string designation;
    public string Designation
        get { return designation; }
        set { designation = value; }

    private string department;
    public string Department
        get { return department; }
        set { department = value; }

Step 3 - Come to the page where conversion is required from datatable to list.
write the similar code as below -
let's say datatable which need to convert to list is dtMain.
   /// <summary>
    /// Method: Convert into list from datatable
    /// </summary>
    /// <returns></returns>
    private List<PropertyClass> GetListfromDataTable()
        DataTable dtMain = GetDataTable();
        //List type object of the property class
        List<PropertyClass> propClass = new List<PropertyClass>();
        foreach (DataRow dr in dtMain.Rows)
            //Object of the propery class
            PropertyClass objPC = new PropertyClass();
            //asign values
            objPC.Name = dr["Name"].ToString();
            objPC.Designation = dr["Designation"].ToString();
            objPC.Department = dr["Department"].ToString();

            //add one row to the list
        //return final list
        return propClass;

Step 4 - Simple call this method, let's say on pageload
protected void Page_Load(object sender, EventArgs e)
       //get datatable value into list on pageload
        List<PropertyClass> pc = GetListfromDataTable();

Your feedback will be appreciated.

Sunday, 8 September 2013


In IIS6.1 I was trying to start my Default Web Site and was getting the following error screen.

The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)

Above error is coming because default port 8080 is not assigned to system. So default website under IIS manager is not able start. 
To Resolve the above error i followed the below steps, and it worked for me.

Step 1 - Go to run, type cmd, command prompt will appear.

Step 2 - We need to find which process is using the default port 8080. To find this type the below command in your command prompt. "Netstart -ano

It will show the default port is using by using process.

Step 3 - As per above screen the port 8080 is using by the process 3152. Now we need to find which application is assigned for process id 3152.
Type "tasklist /fi “PID eq 3152in your command prompt and see the result.

As per the above screenshot the skype application is using the port 8080. we need to kill skype application manually through task manager. 

Step 4 - Start your default website in IIS manager. It will work.

Please try the above described steps, it worked for me.