凌寒飘香

____成风破浪会有时,直把云帆济沧海!

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: :: 管理 ::

public class FileRight:IDisposable
 {
  private SqlDataAdapter dsCommand;
  public SqlConnection mySqlConnection;
  public static  string CONN;
  
  public FileRight()
  {
   CONN=System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
   mySqlConnection = new SqlConnection(CONN);
  }

  public void Dispose()
  {
   Dispose(true);
   GC.SuppressFinalize(true);
  }

  protected virtual void Dispose(bool disposing)
  {
   if (! disposing)
    return;

   if (dsCommand != null)
   {
    if(dsCommand.SelectCommand != null)
    {   
     if( dsCommand.SelectCommand.Connection != null )
      dsCommand.SelectCommand.Connection.Dispose();
     dsCommand.SelectCommand.Dispose();
    }   
    dsCommand.Dispose();
    dsCommand = null;
   }
  }
......
}

posted on 2006-07-18 08:46  凌寒飘香  阅读(152)  评论(0编辑  收藏  举报