Share via


DataConnectionProperties.ReadValueFromString Method

Reads a property value from a connection string starting at a specified index, converts it to the correct type, and updates the index to point to a position following the property name.

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

Syntax

'Declaration
Protected Overridable Function ReadValueFromString ( _
    propertyName As String, _
    connectionString As String, _
    ByRef index As Integer _
) As Object
protected virtual Object ReadValueFromString(
    string propertyName,
    string connectionString,
    ref int index
)
protected:
virtual Object^ ReadValueFromString(
    String^ propertyName, 
    String^ connectionString, 
    int% index
)
abstract ReadValueFromString : 
        propertyName:string * 
        connectionString:string * 
        index:int byref -> Object  
override ReadValueFromString : 
        propertyName:string * 
        connectionString:string * 
        index:int byref -> Object
protected function ReadValueFromString(
    propertyName : String, 
    connectionString : String, 
    index : int
) : Object

Parameters

  • propertyName
    Type: System.String

    The name of the property for which a value is being read.

  • connectionString
    Type: System.String

    The connection string from which the value should be read.

  • index
    Type: System.Int32%

    Index into the connection string from which to start reading the value.

Return Value

Type: System.Object
Returns a substring of the connectionString parameter representing the property value between the input starting index and the end of the property name, converted to the correct type.

Exceptions

Exception Condition
ArgumentNullException

The name and/or connectionString parameter is null.

FormatException

The format of the connection string is invalid.

InvalidCastException

The read string value cannot be converted to the property type.

Remarks

The base implementation of the Parse method calls this method while parsing the input connection string. It uses the index parameter to track the current location in the string and relies on this method and the ReadNameFromString method to update the index appropriately.

The base implementation does the following:

  1. It identifies values that are not enclosed in quotation marks, or that are enclosed in either single or double quotation marks;

  2. it then reads until the first occurrence of a property entry separator character that is not enclosed in any kind of quotation mark;

  3. it then unescapes any embedded quotation mark characters; and

  4. finally, it attempts to convert the string value into the correct type by retrieving the descriptor of the specified property and using its TypeConverter to convert to the correct type.

.NET Framework Security

See Also

Reference

DataConnectionProperties Class

Microsoft.VisualStudio.Data Namespace