这两段代码哪个比较好呀
这两段代码哪个比较好呀
while (mySdr.Read())
{
ListItem myLi = new ListItem(mySdr[ "ProvinceName "].ToString(), mySdr[ "ProvinceId "].ToString());
ddlProvince.Items.Add(myLi);
}
ListItem myLi = null;
while (mySdr.Read())
{
myLi = new ListItem(mySdr[ "ProvinceName "].ToString(), mySdr[ "ProvinceId "].ToString());
ddlProvince.Items.Add(myLi);
}
------解决方案--------------------finally
{
if (myConn.Open)
{
myConn.Close();
}
}