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;
   }
  }
......
}
 
                    
                
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号