简单问题:
使用
using(SqlDataReader reader = new SqlDataReader)
{
..............
reader.Open();
}
这种方式声明reader,在using体中只打开不关闭,问:在using体执行完之后会不会将reader先关闭再释放?
使用
using(SqlDataReader reader = new SqlDataReader)
{
..............
reader.Open();
}
这种方式声明reader,在using体中只打开不关闭,问:在using体执行完之后会不会将reader先关闭再释放?
这一句是不对的,SqlDataReader的构造函数是私有的,不能使用new SqlDataReader来创建实例。
{
if (disposing)
{
try
{
this.Close();
}
catch (Exception exception1)
{
ADP.TraceException(exception1);
}
}
}
还有问题没?
asp和asp.net服务器 50mb 25元/年
我看到了一个网站 50MB asp和 asp.net空间 现在促销,
同学们可以做一个简单的个人网站用来找工作 ,
支持 asp.net 一年才25元!不要错过哦!!!
速度非常快,一般公司企业 足够用了!
http://www.hi876.com 他们的IP 是 211.144.143.13 国务院-国研机房的!
希望能对大家有帮助
官方网址:http://www.aisto.com/roeder/dotnet
微软的帮助都是这样的,一些重要的东西都没写,很多时候自己反射源码来看更方便。不关是SqlDataReader,还有SqlConnection的Dispose方法也会把自己关闭:
protected override void Dispose(bool disposing)
{
if (disposing)
{
switch (this._objectState)
{
case ConnectionState.Open:
{
this.Close();
break;
}
}
this._constr = null;
}
base.Dispose(disposing);
}
其他的xxxxDataReader、xxxxConnection也都是。数据库连接用完即时关闭是非常重要的。