Hi,
I'm trying to write more efficient code, and previously I had the following:
DataTable dtExample = new DataTable();
string _sql = String.Format("select col1,col2,col3 from tablename WHERE col1='{0}'", _myParm);
dtExample = DAL.GetDataTable(_sql);
if (dtExample.Rows.Count > 0)
{
return dtExample;
}
return null;
What I thought would be better, was something along the lines of:
using (DataTable dtExample2 = new DataTable())
{
string _sql = String.Format("select col1,col2,col3 from tablename WHERE col1='{0}'", _myParm);
dtExample2 = DAL.GetDataTable(_sql); // etc
}
However, this gives me the error
Error 1 Cannot assign to 'dtExample2' because it is a 'using variable'
Can someone explain :/
Go to the complete details ...