DataTable.TableName 属性

定义

获取或设置 DataTable 的名称。Gets or sets the name of the DataTable.

public:
 property System::String ^ TableName { System::String ^ get(); void set(System::String ^ value); };
public string TableName { get; set; }
[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).

示例

下面的示例打印 DataTable 对象集合中每个表的 TableNameThe 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

注解

TableName 用于从父 DataSet 对象的 DataTableCollection 返回此表(由 Tables 属性返回)。The TableName is used to return this table from the parent DataSet object's DataTableCollection (returned by the Tables property).

适用于

另请参阅