DataTable.TableName DataTable.TableName DataTable.TableName DataTable.TableName Property

定義

取得或設定 DataTable 的名稱。Gets or sets the name of the DataTable.

public:
 property System::String ^ TableName { System::String ^ get(); void set(System::String ^ value); };
[System.Data.DataSysDescription("DataTableTableNameDescr")]
public string TableName { get; set; }
member this.TableName : string with get, set
Public Property TableName As String

屬性值

DataTable 的名稱。The name of the DataTable.

例外狀況

null 或空字串 ("") 會傳入,並且這個資料表屬於集合。null or empty string ("") is passed in and this table belongs to a collection.

資料表屬於已經具有相同名稱之資料表的集合The table belongs to a collection that already has a table with the same name. (比較是區分大小寫的)。(Comparison is case-sensitive).

範例

下列範例會列印TableName DataTable物件集合中每個資料表的。The following example prints the TableName for each table in a collection of DataTable objects.

private void GetTableNames(DataSet dataSet)
{
    // Print each table's TableName.
    foreach(DataTable table in dataSet.Tables)
    {
        Console.WriteLine(table.TableName);
    }
}
Private Sub GetTableNames(dataSet As DataSet)
     ' Print each table's TableName.
     Dim table As DataTable
     For Each table In dataSet.Tables
         Console.WriteLine(table.TableName)
     Next table
End Sub

備註

是用來從父DataSet DataTableCollection 物件Tables的 (由屬性傳回) 傳回這個資料表。 TableNameThe TableName is used to return this table from the parent DataSet object's DataTableCollection (returned by the Tables property).

適用於

另請參閱