NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

TablesCollection.Item (String)

Gets the table in the collection with the given name (not case-sensitive).

[C#] In C#, this member is the indexer for the TablesCollection class.

[Visual Basic]
Overloads Public Default ReadOnly Property Item( _
   ByVal name As String _
) As DataTable
[C#]
public DataTable this[
   string name
] {get;}
[C++]
public: __property DataTable* get_Item(
   String* name
);
[JScript]
returnValue = TablesCollectionObject.Item(name);
-or-
returnValue = TablesCollectionObject(name);

[JScript] In JScript, you can use the default indexed properties defined by a type, but you cannot explicitly define your own. However, specifying the expando attribute on a class automatically provides a default indexed Item property whose type is Object and whose index type is String.

Arguments [JScript]

name
The name of the table to find.

Parameters [Visual Basic, C#, C++]

name
The name of the table to find.

Property Value

A DataTable with the specified name.

Exceptions

Exception Type Condition
TableOutOfRange(System.Int32) The table name does not exist in the collection.

Remarks

The Contains method can be used to determine if a table with a specified name or index exists.

Example [Visual Basic]

The following example retrieves a single table by name from the TablesCollection.

[Visual Basic]

Private Sub GetTableByName()
   Dim tablesCol As TablesCollection
   Dim dSet As DataSet
   Dim t As DataTable
   ' Presuming a DataGrid is displaying more than one table, get its DataSet.
   Set dSet = DataGrid1.DataGridTable.DataTable.DataSet
   ' Get the TablesCollection.
   Set tablesCol = dSet.Tables
   ' Get a specific table by name.
   Set t = tablesCol("Suppliers")
   Console.WriteLine(t.TableName)
End Sub

See Also

TablesCollection Class | TablesCollection Members | System.Data Namespace | TablesCollection.Item Overload List