Partager via


IVsDataProvider.DeriveSource Method

Derives a DDEX data source that is supported by the DDEX provider, given information about a target data source.

Namespace:  Microsoft.VisualStudio.Data.Core
Assembly:  Microsoft.VisualStudio.Data.Core (in Microsoft.VisualStudio.Data.Core.dll)

Syntax

'Declaration
Function DeriveSource ( _
    connectionString As String _
) As Guid
Guid DeriveSource(
    string connectionString
)
Guid DeriveSource(
    String^ connectionString
)
abstract DeriveSource : 
        connectionString:string -> Guid
function DeriveSource(
    connectionString : String
) : Guid

Parameters

  • connectionString
    Type: System.String

    A data connection string that contains information about a target data source.

Return Value

Type: System.Guid
The derived DDEX data source that is supported by the DDEX provider, or Empty if no data source can be derived.

Remarks

A DDEX provider can add and support one or more DDEX data sources, which represent a more user-friendly concept than a DDEX provider. When more than one data source is supported, you have to be able to inspect information that defines a target data source (a data connection string) and decide which DDEX data source it represents. This method enables DDEX clients to make this determination.

Examples

The following code demonstrates how to call this method on the OLE DB DDEX provider, which natively supports Microsoft SQL Server and Microsoft Access Database File DDEX data sources. The logic for deriving a data source for the OLE DB provider is based on which underlying OLE DB provider is chosen.

using System;
using System.Diagnostics;
using Microsoft.VisualStudio.Data.Core;

public class DDEX_IVsDataProviderExample2
{
    private static readonly Guid MSSqlServerDataSource =
        new Guid("067EA0D9-BA62-43f7-9106-34930C60C528");
    private static readonly Guid MSAccessDBFileDataSource =
        new Guid("466CE797-67A4-4495-B75C-A3FD282E7FC3");

    public static void Example(
        IVsDataProvider provider)
    {
        Guid source1 = provider.DeriveSource("Provider=SQLOLEDB.1");
        Trace.WriteLine(source1); // MSSqlServerDataSource
        Guid source2 = provider.DeriveSource(
            "Provider=Microsoft.Jet.OLEDB.4.0");
        Trace.WriteLine(source2); // MSAccessDBFileDataSource
    }
}

.NET Framework Security

See Also

Reference

IVsDataProvider Interface

Microsoft.VisualStudio.Data.Core Namespace