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 TrivediRank #16 · 50.3K reputationPosted Oct 28, 2013, 10:35 PM EDT
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.
Bineesh ViswanathRank #1,681 · 907 reputationPosted Oct 28, 2013, 10:40 PM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Oct 28, 2013, 10:45 PM EDT
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.