// data access code
}
finally
{
// 3. close the reader
if (rdr != null)
rdr.Close();
// close the connection too
The code above checks the SqlDataReader to make sure it isn''''t null. After the code knows that a good instance of the SqlDataReader exists, it can close it. Listing 1 shows the code for the previous sections in its entirety.
上面的代码检测SqlDataReader,确保它不为空。在代码知道SqlDataReader的一个完好的实例存在,它就能够关闭它。Listing1
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >>
Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved. 闵涛 E_mail:admin@mintao.net(欢迎提供学习资源)
鄂公网安备 42011102001154号
站长:MinTao ICP备案号:鄂ICP备11006601号-18