VistaDB 6
VistaDB.DDA Namespace / IVistaDBDDA Interface / PackDatabase Method / PackDatabase(String,OperationCallbackDelegate) 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).
Delegate called by the Pack operation for progress and informational messages. May be null (Nothing) for no callback.
Example


In This Topic
    PackDatabase(String,OperationCallbackDelegate) 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, _
       ByVal operationCallback As OperationCallbackDelegate _
    ) 
    'Usage
     
    
    Dim instance As IVistaDBDDA
    Dim fileName As System.String
    Dim operationCallback As OperationCallbackDelegate
     
    instance.PackDatabase(fileName, operationCallback)
    void PackDatabase( 
       System.string fileName,
       OperationCallbackDelegate operationCallback
    )

    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).
    operationCallback
    Delegate called by the Pack operation for progress and informational messages. May be null (Nothing) for no callback.
    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