AccessDataSourceDesigner.GetConnectionString Method

Definition

Gets the connection string that is valid at design time for the control that is associated with this designer.

protected:
 override System::String ^ GetConnectionString();
protected override string GetConnectionString ();
override this.GetConnectionString : unit -> string
Protected Overrides Function GetConnectionString () As String

Returns

A String that contains the design-time connection string for the associated AccessDataSource.

Examples

The following code example shows how to use the GetConnectionString method to display the connection string of the Microsoft Access database that is associated with the AccessDataSource control in the control placeholder at design time.

This code example is part of a larger example provided for the AccessDataSourceDesigner class.

// Generate design time markup.
public override string GetDesignTimeHtml()
{
    // Generate a design-time placeholder containing the 
    // DataFile and the ConnectionString properties.
    // Split the ConnectionString into segments so it doesn't make
    // placeholder too wide.
    string[] connectParts = GetConnectionString().Split(new char[] { ';' });
    string connectString = "  " + connectParts[0];

    for (int i = 1; i < connectParts.Length; i++)
        connectString += ";<br>  " + connectParts[i].Trim();

    return CreatePlaceHolderDesignTimeHtml(
        "DataFile: " + DataFile + "<br />" +
        "Connection string:<br />" + connectString);
}
' Generate design time markup.
Public Overrides Function GetDesignTimeHtml() As String
    ' Generate a design-time placeholder containing the 
    ' DataFile and the ConnectionString properties.
    ' Split the ConnectionString into segments so it doesn't make
    ' placeholder too wide.
    Dim connectParts() As String
    connectParts = GetConnectionString().Split((";").ToCharArray())
    Dim connectString As String
    connectString = "  " & connectParts(0)

    Dim i As Integer
    For i = 1 To connectParts.Length - 1
        connectString &= ";<br>  " & connectParts(i).Trim()
    Next

    Return CreatePlaceHolderDesignTimeHtml( _
        "DataFile: " & DataFile & "<br />" & _
        "Connection string:<br />" & connectString)
End Function

Remarks

The GetConnectionString method maps the DataFile property of the control to the designer site, and then uses the ConnectionString property of the control to generate the connection string.

Applies to

See also