DataRowExtensions.SetField 方法

定義

DataRow 中,為指定的資料行設定新的值。Sets a new value for the specified column in the DataRow.

多載

SetField<T>(DataRow, DataColumn, T)

DataRow 中,為指定的資料行設定新的值。Sets a new value for the specified column in the DataRow. SetField<T>(DataRow, DataColumn, T) 方法也支援可為 null 的型別。The SetField<T>(DataRow, DataColumn, T) method also supports nullable types.

SetField<T>(DataRow, Int32, T)

DataRow (會針對它呼叫此方法) 中,為指定的資料行設定新的值。Sets a new value for the specified column in the DataRow the method is called on. SetField<T>(DataRow, Int32, T) 方法也支援可為 null 的型別。The SetField<T>(DataRow, Int32, T) method also supports nullable types.

SetField<T>(DataRow, String, T)

DataRow 中,為指定的資料行設定新的值。Sets a new value for the specified column in the DataRow. SetField<T>(DataRow, String, T) 方法也支援可為 null 的型別。The SetField<T>(DataRow, String, T) method also supports nullable types.

SetField<T>(DataRow, DataColumn, T)

DataRow 中,為指定的資料行設定新的值。Sets a new value for the specified column in the DataRow. SetField<T>(DataRow, DataColumn, T) 方法也支援可為 null 的型別。The SetField<T>(DataRow, DataColumn, T) method also supports nullable types.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static void SetField(System::Data::DataRow ^ row, System::Data::DataColumn ^ column, T value);
public static void SetField<T> (this System.Data.DataRow row, System.Data.DataColumn column, T value);
static member SetField : System.Data.DataRow * System.Data.DataColumn * 'T -> unit
<Extension()>
Public Sub SetField(Of T) (row As DataRow, column As DataColumn, value As T)

類型參數

T

泛型參數,會指定資料行的實值型別。A generic parameter that specifies the value type of the column.

參數

row
DataRow

輸入 DataRow,作用為擴充方法的 this 執行個體。The input DataRow, which acts as the this instance for the extension method.

column
DataColumn

輸入 DataColumn,指定要擷取哪個資料列值。The input DataColumn specifies which row value to retrieve.

value
T

指定之資料行的新資料列值,這個值的型別為 TThe new row value for the specified column, of type T.

例外狀況

找不到 column 指定的資料行。The column specified by column cannot be found.

columnnullThe column is null.

嘗試在已刪除的資料列上設定值時發生。Occurs when attempting to set a value on a deleted row.

基礎資料行的實值型別不能轉換成泛型參數 T 所指定的型別。The value type of the underlying column could not be cast to the type specified by the generic parameter, T.

備註

如果 valuenullSetField 方法會將null值轉換成基礎 DataColumn中的 ValueIf value is null, the SetField method converts the null value to Value in the underlying DataColumn.

SetField 方法不會執行任何類型轉換。The SetField method does not perform any type conversions. 不過,這並不表示不會進行型別轉換。This does not mean, however, that a type conversion will not occur. SetField 方法會公開 DataRow 類別的 ADO.NET 2.0ADO.NET 2.0 行為。The SetField method exposes the ADO.NET 2.0ADO.NET 2.0 behavior of the DataRow class. DataRow 物件可以執行類型轉換,然後轉換後的值會儲存到資料列。A type conversion could be performed by the DataRow object and the converted value would then be saved to the row.

您可以從基礎 DataRow 物件,透過 SetField 方法傳遞例外狀況。Exceptions can be passed up through the SetField method from the underlying DataRow object.

SetField<T>(DataRow, Int32, T)

DataRow (會針對它呼叫此方法) 中,為指定的資料行設定新的值。Sets a new value for the specified column in the DataRow the method is called on. SetField<T>(DataRow, Int32, T) 方法也支援可為 null 的型別。The SetField<T>(DataRow, Int32, T) method also supports nullable types.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static void SetField(System::Data::DataRow ^ row, int columnIndex, T value);
public static void SetField<T> (this System.Data.DataRow row, int columnIndex, T value);
static member SetField : System.Data.DataRow * int * 'T -> unit
<Extension()>
Public Sub SetField(Of T) (row As DataRow, columnIndex As Integer, value As T)

類型參數

T

泛型參數,會指定資料行的實值型別。A generic parameter that specifies the value type of the column.

參數

row
DataRow

輸入 DataRow,作用為擴充方法的 this 執行個體。The input DataRow, which acts as the this instance for the extension method.

columnIndex
Int32

要設定其值的資料行之以零起始的序數。The zero-based ordinal of the column to set the value of.

value
T

指定之資料行的新資料列值,這個值的型別為 TThe new row value for the specified column, of type T.

例外狀況

嘗試在已刪除的資料列上設定值時發生。Occurs when attempting to set a value on a deleted row.

ordinal 引數超出範圍。The ordinal argument is out of range.

基礎資料行的實值型別不能轉換成泛型參數 T 所指定的型別。The value type of the underlying column could be not cast to the type specified by the generic parameter, T.

備註

如果 valuenullSetField 方法會將null值轉換成基礎 DataColumn中的 ValueIf value is null, the SetField method converts the null value to Value in the underlying DataColumn.

SetField 方法不會執行任何類型轉換。The SetField method does not perform any type conversions. 不過,這並不表示不會進行型別轉換。This does not mean, however, that a type conversion will not occur. SetField 方法會公開 DataRow 類別的 ADO.NET 2.0ADO.NET 2.0 行為。The SetField method exposes the ADO.NET 2.0ADO.NET 2.0 behavior of the DataRow class. DataRow 物件可以執行類型轉換,然後轉換後的值會儲存到資料列。A type conversion could be performed by the DataRow object and the converted value would then be saved to the row.

您可以從基礎 DataRow 物件,透過 SetField 方法傳遞例外狀況。Exceptions can be passed up through the SetField method from the underlying DataRow object.

SetField<T>(DataRow, String, T)

DataRow 中,為指定的資料行設定新的值。Sets a new value for the specified column in the DataRow. SetField<T>(DataRow, String, T) 方法也支援可為 null 的型別。The SetField<T>(DataRow, String, T) method also supports nullable types.

public:
generic <typename T>
[System::Runtime::CompilerServices::Extension]
 static void SetField(System::Data::DataRow ^ row, System::String ^ columnName, T value);
public static void SetField<T> (this System.Data.DataRow row, string columnName, T value);
static member SetField : System.Data.DataRow * string * 'T -> unit
<Extension()>
Public Sub SetField(Of T) (row As DataRow, columnName As String, value As T)

類型參數

T

泛型參數,會指定資料行的實值型別。A generic parameter that specifies the value type of the column.

參數

row
DataRow

輸入 DataRow,作用為擴充方法的 this 執行個體。The input DataRow, which acts as the this instance for the extension method.

columnName
String

要設定其值的資料行名稱。The name of the column to set the value of.

value
T

指定之資料行的新資料列值,這個值的型別為 TThe new row value for the specified column, of type T.

例外狀況

找不到 columnName 指定的資料行。The column specified by columnName cannot be found.

嘗試在已刪除的資料列上設定值時發生。Occurs when attempting to set a value on a deleted row.

基礎資料行的實值型別不能轉換成泛型參數 T 所指定的型別。The value type of the underlying column could not be cast to the type specified by the generic parameter, T.

備註

如果 valuenullSetField 方法會將null值轉換成基礎 DataColumn中的 ValueIf value is null, the SetField method converts the null value to Value in the underlying DataColumn.

SetField 方法不會執行任何類型轉換。The SetField method does not perform any type conversions. 不過,這並不表示不會進行型別轉換。This does not mean, however, that a type conversion will not occur. SetField 方法會公開 DataRow 類別的 ADO.NET 2.0ADO.NET 2.0 行為。The SetField method exposes the ADO.NET 2.0ADO.NET 2.0 behavior of the DataRow class. DataRow 物件可以執行類型轉換,然後轉換後的值會儲存到資料列。A type conversion could be performed by the DataRow object and the converted value would then be saved to the row.

您可以從基礎 DataRow 物件,透過 SetField 方法傳遞例外狀況。Exceptions can be passed up through the SetField method from the underlying DataRow object.

適用於