VistaDB 6
VistaDB.Provider Namespace / VistaDBConnection Class / ConnectionString Property
Example


In This Topic
    ConnectionString Property (VistaDBConnection)
    In This Topic
    Gets or sets the string used to open the connection.Gets or sets the string used to open the connection.
    Syntax
    'Declaration
     
    
    Public Overrides NotOverridable Property ConnectionString As System.String
    'Usage
     
    
    Dim instance As VistaDBConnection
    Dim value As System.String
     
    instance.ConnectionString = value
     
    value = instance.ConnectionString
    public override System.string ConnectionString {get; set;}

    Property Value

    The connection string used to establish the initial connection. The exact contents of the connection string depend on the specific data source for this connection. The default value is an empty string.
    Remarks

    The following list shows the valid names for keyword values within the ConnectionString.

    Parameter Description
    Data Source Database file name. You may also use the |DataDirectory| tag (see below)
    Open Mode Database open mode. Can be one of the following values: ExclusiveReadWrite, ExclusiveReadOnly, SingleProcessReadWrite, SingleProcessReadOnly, MultiProcessReadWrite, MultiProcessReadOnly, SharedReadOnly. Older values NonexclusiveReadWrite and NonexclusiveReadOnly are also permitted and will be mapped to the corresponding MutliProcess- mode. If not specified, defaults to SingleProcessReadWrite.
    Password The Password (which may also be a phrase) used to encrypt the database.
    Max Pool Size The maximum number of (inactive) connections to be kept in the pool awaiting possible reuse. Default value is 100.
    Pooling Connection Pooling support enabled status. Default is disabled.
    Context Connection May be assigned only for CLR stored procedures. If set to true the context connection is used.
    Isolated Storage If it is set to true the database placed in isolated storage.
    Transaction Mode On, Off, or ignore for how the connection should treat transactions. Default is On.
    Compatibility Mode Legacy, Normal, or Strict for how the connection should handle syntax compatibility. Default is Normal

    The VistaDBConnectionStringBuilder class provides functionality for creating and managing the contents of connection strings. To simplify managing paths you can use the |DataDirectory| variable. By default, the |DataDirectory| variable will be expanded as follow:

    • For applications placed in a directory on the user machine, this will be the app's (.exe) folder.
    • For apps running under ClickOnce, this will be a special data folder created by ClickOnce
    • For Web apps, this will be the App_Data folder

    Under the hood, the value for |DataDirectory| simply comes from a property on the app domain. It is possible to change that value and override the default behavior by doing this:

    <code lang="C#"> AppDomain.CurrentDomain.SetData("DataDirectory", newpath) </code>

    Example
    The following example creates a VistaDBConnection and sets the ConnectionString property before opening the connection.
    public VistaDBConnection 
    OpenConnection()
    {
        string connectionString = @"Data Source = 'C:\VistaDB.vdb6'; Open Mode = ExclusiveReadWrite";
        VistaDBConnection connection = new VistaDBConnection(connectionString);
        connection.Open();
        return connection;
    }
    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

    Reference

    VistaDBConnection Class
    VistaDBConnection Members
    Class VistaDBConnection
    Class VistaDBConnectionStringBuilder