Gets or sets the name of the table.
[Visual Basic] Public Property TableName As String [C#] public string TableName {get; set;} [C++] public: __property String* get_TableName(); public: __property void set_TableName(String*); [JScript] public function get TableName() : String; public function set TableName(String);
The name of the table.
Exception Type | Condition |
---|---|
ArgumentException | A a null reference (in Visual Basic Nothing) or empty string ("") is passed in and this table belongs to a collection. |
DuplicateNameException | The table belongs to a collection that already has a table with the same name (and the comparison is not case-sensitive). |
The TableName is used to return this table from the parent DataSet object's TablesCollection (returned by the Tables property).
The following example prints the TableName for each table in a collection of DataTable objects.
[Visual Basic]
Private Sub GetTableNames() Dim t As DataTable Dim cols As TablesCollection ' Set cols to a DataSet object's Tables collection. cols = myDataSet.Tables ' Print each table's TableName. For Each t in cols Console.WriteLine(t.TableName) Next End Sub
DataTable Class | DataTable Members | System.Data Namespace | DataSet | Tables