日期:2014-05-19  浏览次数:20779 次

DataReader使用完毕之后,能不能自动关闭
DataReader使用完毕之后,能不能自动关闭DataReader和所对应的连接
cmd.ExecuteReader(CommandBehavior.CloseConnection);  
这个只能是手动关闭DataReader后才会关闭数据库连接

------解决方案--------------------
using ( SqlDataReader sqlReader = sqlCmd.EndExecuteReader( asyncResult ) )
{
GridView1.DataSource = sqlReader;
GridView1.DataBind( );
}