VistaDB 6
VistaDB.DDA Namespace / IVistaDBDDA Interface / PackDatabase Method / PackDatabase(String,String,String,Int32,Int32,Boolean,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 existing database. Pass null (Nothing in Visual Basic) for an unencrypted database.
Encryption key to use for the new (packed) database. Pass null for a unencrypted database.
New page size.Pass a 0 here to leave the page size at the current setting.
New locale LocaleID. Pass a value of 0 to leave the LocaleID with it's current setting.
New case sensitivity setting. (Cannot default to existing setting using this overload. Check original setting first if it is not already known and not intending to override it.)
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,String,Int32,Int32,Boolean,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 newencryptionKeyString As System.String, _
       ByVal newPageSize As System.Integer, _
       ByVal newLCID As System.Integer, _
       ByVal newCaseSensitive As System.Boolean, _
       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 newencryptionKeyString As System.String
    Dim newPageSize As System.Integer
    Dim newLCID As System.Integer
    Dim newCaseSensitive As System.Boolean
    Dim backup As System.Boolean
    Dim operationCallbackDelegate As OperationCallbackDelegate
     
    instance.PackDatabase(fileName, encryptionKeyString, newencryptionKeyString, newPageSize, newLCID, newCaseSensitive, backup, operationCallbackDelegate)
    void PackDatabase( 
       System.string fileName,
       System.string encryptionKeyString,
       System.string newencryptionKeyString,
       System.int newPageSize,
       System.int newLCID,
       System.bool newCaseSensitive,
       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 existing database. Pass null (Nothing in Visual Basic) for an unencrypted database.
    newencryptionKeyString
    Encryption key to use for the new (packed) database. Pass null for a unencrypted database.
    newPageSize
    New page size.Pass a 0 here to leave the page size at the current setting.
    newLCID
    New locale LocaleID. Pass a value of 0 to leave the LocaleID with it's current setting.
    newCaseSensitive
    New case sensitivity setting. (Cannot default to existing setting using this overload. Check original setting first if it is not already known and not intending to override it.)
    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
    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