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;
   }
  }
......
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-20
  • 2021-11-21
  • 2022-12-23
  • 2021-12-02
  • 2022-01-11
  • 2022-01-16
猜你喜欢
  • 2021-10-19
  • 2021-09-28
  • 2022-03-02
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
  • 2021-12-28
相关资源
相似解决方案