Sir, I need your help in the following subject:-
Please take a look to the functions below:-
Function:1
public void EmployeeAdd()
{
DataTable dtbl=new DataTable()
try
{
EmployeeSp spEmployee =new EmployeeSp()
dtbl=spEmployee.EmployeeAdd()
}
catch(Exception)
{
throw;
}
}
Function:2
public void Function1()
{
try
{
EmployeeSp spEmployee =new EmployeeSp()
cmbEmployee.DataSource=spEmployee.EmployeeAdd()
}
catch(Exception)
{
throw;
}
}
Please explain the difference between above two functions. which will be more faster?
Loading

Jaganathan BantheswaranPosted Nov 12, 2013, 5:40 AM
Function:1 can be used if you want to use the data returned from EmployeeAdd() func call after binding the data to combobox, otherwise Function:2 can be used.
Function:2 would be fast as we are skipping a line of execution. i.e.
dtbl=spEmployee.EmployeeAdd() // we are skipping this line in Function:2, instead we assigning directly to the datasource.
Jignesh TrivediPosted Nov 12, 2013, 6:53 AM
If you functionality is limited to assigning the datasource then better to go with function:2 and also I think there is no much performance difference between this two function.
Here your function:1 doesnot return any value, so I think no use of function: 1 :)