I know that it is recommended to use the using statement with sqldatareader, but I was wondering if this is necessary when you directly set the control's data source to the data source.
in some places of my code I do this .....
using (SqlDataReader reader = getReader())
{
while (reader.Read())
{
}
}
when binding to a control i do this .....
ddlCustomer.DataSource = getReader();
ddlCustomer.DataBind();
In the second case, I need to use the using statement. Should I first declare SqlDataReader in the using statement, and then set the DataSource for this object. It seems that the code is more of a mess, so I was hoping to bind the SqlDataReader preemptions to the SqlDataReader.
thank
source
share