Npgsql.NpgsqlConnection.Dispose C# (CSharp) Method

Dispose() protected method

Releases all resources used by the NpgsqlConnection.
protected Dispose ( bool disposing ) : void
disposing bool true when called from Dispose(); /// false when being called from the finalizer.
return void
        protected override void Dispose(bool disposing)
        {
            if (disposed)
                return;

            _postponingDispose = false;
            if (disposing)
            {
                NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Dispose");
                Close();
                if (_postponingClose)
                {
                    _postponingDispose = true;
                    return;
                }
            }

            base.Dispose(disposing);
            disposed = true;
        }

Usage Example

示例#1
0
 public static bool Connection_Test(ENTITE.Serveur bean)
 {
     if (bean.Control_())
     {
         NpgsqlConnection con = new NpgsqlConnection();
         try
         {
             string constr = "PORT=" + bean.getPort + ";TIMEOUT=15;POOLING=True;MINPOOLSIZE=1;MAXPOOLSIZE=20;COMMANDTIMEOUT=20;COMPATIBLE= 2.0.14.3;DATABASE=" + bean.getDatabase + ";HOST=" + bean.getAdresse + ";PASSWORD="******";USER ID=" + bean.getUser + "";
             con = new NpgsqlConnection(constr);
             con.Open();
             return true;
         }
         catch (NpgsqlException ex)
         {
             Messages.Exception(ex);
             return false;
         }
         finally
         {
             con.Close();
             con.Dispose();
         }
     }
     return false;
 }
All Usage Examples Of Npgsql.NpgsqlConnection::Dispose