This documentation is archived and is not being maintained.

DbConnectionStringBuilder.EquivalentTo Method

Compares the connection information in this DbConnectionStringBuilder object with the connection information in the supplied object.

Namespace: System.Data.Common
Assembly: System.Data (in

Public Overridable Function EquivalentTo ( _
	connectionStringBuilder As DbConnectionStringBuilder _
) As Boolean
Dim instance As DbConnectionStringBuilder
Dim connectionStringBuilder As DbConnectionStringBuilder
Dim returnValue As Boolean

returnValue = instance.EquivalentTo(connectionStringBuilder)
public boolean EquivalentTo (
	DbConnectionStringBuilder connectionStringBuilder
public function EquivalentTo (
	connectionStringBuilder : DbConnectionStringBuilder
) : boolean
Not applicable.



The DbConnectionStringBuilder to be compared with this DbConnectionStringBuilder object.

Return Value

true if the connection information in both of the DbConnectionStringBuilder objects causes an equivalent connection string; otherwise false.

Comparisons on key names are case insensitive; value comparisons are case sensitive.

The EquivalentTo method returns true if the key/value pairs are equal, regardless of their order. The connection behavior of the two connection strings are equivalent, because order is never significant within connection strings. However, different order may affect connection pooling behavior of connections based on these connection strings.

Sub Main()
    Dim builder1 As New DbConnectionStringBuilder
    builder1.ConnectionString = _
    Console.WriteLine("builder1 = " & builder1.ConnectionString)

    Dim builder2 As New DbConnectionStringBuilder
    builder2.ConnectionString = _
    Console.WriteLine("builder2 = " & builder2.ConnectionString)

    Dim builder3 As New DbConnectionStringBuilder
    builder3.ConnectionString = _
    Console.WriteLine("builder3 = " & builder3.ConnectionString)

    ' builder1 and builder2 contain the same
    ' keys and values, in different order, and the 
    ' keys are not consistently cased. They are equivalent.
    Console.WriteLine("builder1.EquivalentTo(builder2) = " & _

    ' builder2 and builder3 contain the same key/value pairs in the 
    ' the same order, but the value casing is different, so they're
    ' not equivalent.
    Console.WriteLine("builder2.EquivalentTo(builder3) = " & _

    Console.WriteLine("Press Enter to continue.")
End Sub

This sample displays the following output:

builder1 = value1=SomeValue;value2=20;value3=30;value4=40
builder2 = value2=20;value3=30;value4=40;value1=SomeValue
builder3 = value2=20;value3=30;value4=40;value1=SOMEVALUE
builder1.EquivalentTo(builder2) = True
builder2.EquivalentTo(builder3) = False

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0