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.StringThe name of the property for which a value is being read.
connectionString
Type: System.StringThe 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:
It identifies values that are not enclosed in quotation marks, or that are enclosed in either single or double quotation marks;
it then reads until the first occurrence of a property entry separator character that is not enclosed in any kind of quotation mark;
it then unescapes any embedded quotation mark characters; and
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
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.