DatabaseProvider..::.CalculateConnectionString Method Home
.NET Framework Class Library
DatabaseProvider..::.CalculateConnectionString Method

Returns the calculated connection string for the database provider.

Namespace:  Microsoft.Web.Management.DatabaseManager
Assembly:  Microsoft.Web.Management.DatabaseManager (in Microsoft.Web.Management.DatabaseManager.dll)
Syntax

'Usage

Dim instance As DatabaseProvider
Dim arguments As ICollection(Of ConnectionArgument)
Dim returnValue As String

returnValue = instance.CalculateConnectionString(arguments)

'Declaration

Public MustOverride Function CalculateConnectionString ( _
    arguments As ICollection(Of ConnectionArgument) _
) As String

Parameters

arguments
Type: System.Collections.Generic..::.ICollection<(Of <(ConnectionArgument>)>)
The ICollection object that contains a collection of ConnectionArgument objects.

Return Value

Type: System..::.String
The calculated database connection string.
Remarks

Your provider must implement the CalculateConnectionString method in order to generate a connection string based on the arguments that your database provider requires.

Examples

The following code sample illustrates an example CalculateConnectionString method that returns the connection string for a Microsoft Access database provider.


    Public Overrides Function CalculateConnectionString( _
            ByVal arguments As System.Collections.Generic.ICollection( _
            Of Microsoft.Web.Management.DatabaseManager.ConnectionArgument)) As String

        Dim builder As OleDbConnectionStringBuilder = New OleDbConnectionStringBuilder
        For Each argument As ConnectionArgument In arguments
            Select Case (argument.Name)
                Case "Provider"
                    builder.Provider = argument.Value
                Case "Data Source"
                    builder.DataSource = argument.Value
                Case "Jet OLEDB:Database Password"
                    builder.Add(argument.Name, argument.Value)
                Case Else
                    Throw New ArgumentException(String.Format("The argument {0} is unexpected for this database provider!", argument.Name))
            End Select
        Next
        Return builder.ToString

    End Function



Permissions

  • Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see .
See Also

Reference

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View