• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • C#高級編程:數據庫連接[2]

    發表于:2008-05-15來源:作者:點擊數: 標簽:數據庫高級
    關鍵字: .net catch ( Exception ex ) { // Do something about the exception } finally { // Ensure that the connection is freed conn.Close ( ) ; } 在finally塊中,可以釋放已經使用的任何資源。這種方式的惟一麻煩是必須確保關閉連接。很容易忘記在fi
    關鍵字:.netcatch ( Exception ex )
        {
           // Do something about the exception
        }
        finally
        {
           // Ensure that the connection is freed
           conn.Close ( ) ;
        }

        在finally塊中,可以釋放已經使用的任何資源。這種方式的惟一麻煩是必須確保關閉連接。很容易忘記在finally塊中添加關閉連接的命令,所以應在編碼風格上添加一些不容易出現反常情況的內容。

        另外,在給定的方法中可能會打開許多資源(例如兩個數據庫連接和一個文件),這樣try…catch…finally塊的層次有時可能不容易看懂。但還有另一個方式可以確保資源的關閉—— 使用using語句。

        第二種方式—— 使用using語句塊
        在開發C#的過程中,.NET在對象不再引用之后清理它們的方法是使用非決定性的析構方式,這已經引起了一個非常熱烈的討論。

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>