共用方式為


DataConnectionProperties.ReadValueFromString 方法

在屬性名稱後面,會從指定的索引開始之連接字串的屬性值,將它轉換為正確的型別,並更新指向索引位置。

命名空間:  Microsoft.VisualStudio.Data
組件:  Microsoft.VisualStudio.Data (在 Microsoft.VisualStudio.Data.dll 中)

語法

'宣告
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

參數

  • propertyName
    型別:System.String
    要從中讀取值的屬性名稱。
  • connectionString
    型別:System.String
    值應該閱讀的連接字串。
  • index
    型別:System.Int32%
    索引的連接字串中開始讀取的值。

傳回值

型別:System.Object
傳回表示輸入範圍的 connectionString 參數中的子字串屬性值開始索引和屬性名稱的尾端,轉換為正確的型別。

例外狀況

例外狀況 條件
ArgumentNullException

name 和 connectionString 參數為 null。

FormatException

連接字串的格式無效。

InvalidCastException

讀取的字串值不能轉換為屬性型別 (Property Type)。

備註

Parse 方法的基底實作會呼叫這個方法,以剖析輸入連接字串。它會使用 index 追蹤參數字串的目前位置並依賴這個方法和方法 ReadNameFromString 適當地更新索引。

基底實作會執行下列動作:

  1. 它會識別在引號未包含在引號中,或是包在單引號或雙引號括住的值;

  2. 然後它會讀取直到在任何類型不會封入引號屬性項目分隔字元的第一個符合項目,

  3. 然後不逸出任何內嵌引號字元;而且

  4. 最後,它會嘗試將字串值轉換成正確型別傳遞至以擷取指定的屬性描述項和使用它的 TypeConverter 轉換為正確的型別。

.NET Framework 安全性

請參閱

參考

DataConnectionProperties 類別

Microsoft.VisualStudio.Data 命名空間