Bineesh  Viswanath

Bineesh Viswanath

  • NA
  • 1k
  • 780.2k

will DataTable within function Reduce Program Performance?

Oct 29 2013 2:18 AM
Sir, I have a doubt in datatable use in C#.

We often use the function from a class like this:-

I here writing two methods. Please go through my two methods

Method:1

public void EmployeeNameComboFill()
 {

    try
            {
                DataTable dtb= new DataTable();
                EmployeeSP SpEmployee = new  EmployeeSP();
                dtbl = SpEmployee .EmployeeNameComboFill();
                cmbName.DataSource = dtbl;
                cmbName.ValueMember = "employeeId";
                cmbName.DisplayMember = "employeeName";
                cmbName.SelectedIndex = -1;

            }
            catch (Exception ex)
            {
                throw;
            }
}


Method:2

public void EmployeeNameComboFill()
 {

    try
            {
                EmployeeSP SpEmployee = new  EmployeeSP();
                cmbName.DataSource=SpEmployee .EmployeeNameComboFill();
                cmbName.ValueMember = "employeeId";
                cmbName.DisplayMember = "employeeName";
                cmbName.SelectedIndex = -1;

            }
            catch (Exception ex)
            {
                throw;
            }
}

In the above functions, which one is faster or standard?

Answers (3)