VistaDB 6
VistaDB.DDA Namespace / IVistaDBDDA Interface / PackDatabase Method / PackDatabase(String) Method
Filename of database to pack, including extension. May use a full path or a path relative to the current working directory (same as Data Source in a connection string).
Example


In This Topic
    PackDatabase(String) Method
    In This Topic
    Pack database to compress free space in the database (also used to upgrade to the current supported format). Packing requires a new exclusive connection, so all other connections to that database must be closed (including clearing all pools) from this and any other process.
    Syntax
    'Declaration
     
    
    Overloads Sub PackDatabase( _
       ByVal fileName As System.String _
    ) 
    'Usage
     
    
    Dim instance As IVistaDBDDA
    Dim fileName As System.String
     
    instance.PackDatabase(fileName)
    void PackDatabase( 
       System.string fileName
    )

    Parameters

    fileName
    Filename of database to pack, including extension. May use a full path or a path relative to the current working directory (same as Data Source in a connection string).
    Example
    Sub Main()
       Dim DDAObj As VistaDB.DDA.IVistaDBDDA
       DDAObj = VistaDB.DDA.VistaDBEngine.Connections.OpenDDA()
       Dim OldPassword As String
       Dim NewPassword As String
       
       ' In this example we are modifying a database that had no encryptionKey to now have one
       ' Reverse to remove a encryptionKey
       OldCryptoPhrase = Nothing
       NewPhrase = "pass.word"
       DDAObj.PackDatabase("C:\test.vdb6", OldCryptoPhrase, 
            NewPhrase, 0, 0, True, True, Nothing)
            
       ' You do not have to provide a path - .Net looks in the current working directory by default.
       DDAObj.PackDatabase("test.vdb6", Nothing, False, Nothing)
    End Sub
    {
       IVistaDBDDA DDAObj = VistaDB.DDA.VistaDBEngine.Connections.OpenDDA();
       string OldPhrase = null;
       string NewPhrase = "pass.word";
       // You do not have to provide a path - Dot Net looks in the current working directory by default.
       DDAObj.PackDatabase(fileName, OldPhrase, NewPhrase, pageSize, LCID, 
           caseSensitive, false, new OperationCallbackDelegate(this.OnPackInfo));
    }
     
    public void OnPackInfo(VistaDB.DDA.IVistaDBOperationCallbackInfo operationDelegate)
    {
       if (operationDelegate.Progress < 0)
          return;
     
       int ProgressPercent = operationDelegate.Progress;
     
       string ProgressText = String.Concat("Performing ", 
           operationDelegate.Operation.ToString()," on ",
           operationDelegate.ObjectName.ToString(),":");
     
    }
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also