System.Data Namespace DataTable Class
Sets or retrieves the name of the the DataTable.
Script |
DataTable.TableName [ = strName ] |
The property is read/write with no default value.
Exception Type |
Condition |
ArgumentException |
Occurs when a null reference or empty string ( "" ) is passed in and this table belongs to a collection. |
DuplicateNameException |
Occurs when 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 DataTableCollection ( returned by the Tables property ).
The following example prints the TableName for each table in a collection of DataTable objects.
private void TableNameDemo ( DataSet myDataSet ) {
// print each table's TableName.
foreach ( DataTable tbl in myDataSet.Tables ) {
Response.Write ( tbl.TableName );
}
}
Private Sub TableNameDemo ( myDataSet As DataSet )
' print each table's TableName.
Dim tbl As DataTable
For Each tbl In myDataSet.Tables
Response.Write ( tbl.TableName )
Next tbl
End Sub |
|
C# |
VB |
DataTable Members DataSet Tables