This documentation is archived and is not being maintained.

DataTableMappingCollection.Count Property

Gets the number of DataTableMapping objects in the collection.

[Visual Basic]
Public Overridable ReadOnly Property Count As Integer  Implements _
   ICollection.Count
[C#]
public virtual int Count {get;}
[C++]
public: __property virtual int get_Count();
[JScript]
public function get Count() : int;

Property Value

The number of DataTableMapping objects in the collection.

Implements

ICollection.Count

Example

[Visual Basic, C#, C++] The following example creates a DataTableMappingCollection, adds DataTableMapping objects to the collection, and displays a list of the mapped source tables.

[Visual Basic] 
Public Sub CreateTableMappings()
    Dim myTableMappings As New DataTableMappingCollection()
    myTableMappings.Add("Categories", "DataCategories")
    myTableMappings.Add("Orders", "DataOrders")
    myTableMappings.Add("Products", "DataProducts")
    Dim myMessage As String = "TableMappings:" + ControlChars.Cr
    Dim i As Integer
    For i = 0 To myTableMappings.Count - 1
        myMessage += i.ToString() + " " + myTableMappings(i).ToString() _
           + ControlChars.Cr
    Next i
    MessageBox.Show(myMessage)
End Sub

[C#] 
public void CreateTableMappings() {
   DataTableMappingCollection myTableMappings = new DataTableMappingCollection();
   myTableMappings.Add("Categories","DataCategories");
   myTableMappings.Add("Orders","DataOrders");
   myTableMappings.Add("Products","DataProducts");
   string myMessage = "TableMappings:\n";
   for(int i=0;i < myTableMappings.Count;i++)
   {
      myMessage += i.ToString() + " " + myTableMappings[i].ToString() + "\n";
   }
   MessageBox.Show(myMessage);
}

[C++] 
void ShowTableMappings() {
   // ...
   // create myDataAdapter
   // ...
   myDataAdapter->TableMappings->Add(S"Categories",S"DataCategories");
   myDataAdapter->TableMappings->Add(S"Orders",S"DataOrders");
   myDataAdapter->TableMappings->Add(S"Products",S"DataProducts");
   String* myMessage = S"Table Mappings:\n";
   for(int i=0;i < myDataAdapter->TableMappings->Count;i++) {
       myMessage = String::Concat( myMessage, __box(i)->ToString(), S" ",
         myDataAdapter->TableMappings->Item[i]->ToString(), S"\n" );
   }
   MessageBox::Show(myMessage);
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

DataTableMappingCollection Class | DataTableMappingCollection Members | System.Data.Common Namespace

Show: