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?
Loading

Jignesh TrivediPosted Oct 29, 2013, 2:45 AM
Hi,
to bind dropdownlist with data reader we have two way
Please refer following link
1) http://www.dotnetspider.com/resources/39106-Bind-Dropdown-list-with-Data-Reader.aspx
2) http://rakeshcalls-aspdotnet.blogspot.in/2011/06/how-to-bind-dropdownlist-with.html
hope this will help you.
Bineesh ViswanathPosted Oct 29, 2013, 2:40 AM
Jignesh TrivediPosted Oct 29, 2013, 2:35 AM
Hi,
As per me, In both method have same performance. because base method return datatable..
you can use datareader instead of datatable to improve the performance.
please refer performance comparision.
http://msdn.microsoft.com/en-us/library/ms978388.aspx
hope this will help you.