VistaDB 6
VistaDB.DDA Namespace / IVistaDBDDA Interface / PackDatabase Method / PackDatabase(String,String,Boolean,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).
Encryption key for the database (not changing). Pass null (Nothing in Visual Basic) for an unencrypted database.
True to create a backup copy of the pre-packed database with the same name + ".backupCopy" appended to the end of the filename. If a backup file by that name already exists it will be overwritten.
OperationCallbackDelegate method for feedback of pack progress. May be null (Nothing) for no callback.
Example


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

    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).
    encryptionKeyString
    Encryption key for the database (not changing). Pass null (Nothing in Visual Basic) for an unencrypted database.
    backup
    True to create a backup copy of the pre-packed database with the same name + ".backupCopy" appended to the end of the filename. If a backup file by that name already exists it will be overwritten.
    operationCallbackDelegate
    OperationCallbackDelegate method for feedback of pack progress. May be null (Nothing) for no callback.
    Example
    ' VB.NET Code
    Sub Main()
       Dim DDAObj As VistaDB.DDA.IVistaDBDDA
       DDAObj = VistaDB.DDA.VistaDBEngine.Connections.OpenDDA()
       DDAObj.PackDatabase("C:\dest.vdb6", Nothing, False, 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
    public void PackingFunction() 
    { 
        IVistaDBDDA DDAObj = VistaDB.DDA.VistaDBEngine.Connections.OpenDDA(); 
        // You do not have to provide a path - Dot Net looks in the current working directory by default. 
        DDAObj.PackDatabase(fileName, null, 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