Export (0) Print
Expand All

OleDbParameterCollection.Count Property

Gets the number of OleDbParameter 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 OleDbParameter objects in the collection.

Implements

ICollection.Count

Example

[Visual Basic, C#, C++] The following example creates an OleDbParameterCollection, adds instances of OleDbParameter to the collection, displays the names of the OleDbParameter objects, and then clears the collection.

[Visual Basic] 
Public Sub CreateOleDbParamColl(myCommand As OleDbCommand)
    Dim myParamCollection As OleDbParameterCollection = myCommand.Parameters
    myParamCollection.Add("@CategoryName", OleDbType.Char)
    myParamCollection.Add("@Description", OleDbType.Char)
    myParamCollection.Add("@Picture", OleDbType.Binary)
    Dim myParamNames As String = ""
    Dim i As Integer
    For i = 0 To myParamCollection.Count - 1
        myParamNames += myParamCollection(i).ToString() + ControlChars.Cr
    Next i
    MessageBox.Show(myParamNames)
    myParamCollection.Clear()
End Sub 'CreateOleDbParamColl

[C#] 
public void CreateOleDbParamColl(OleDbCommand myCommand) {
    OleDbParameterCollection myParamCollection = myCommand.Parameters;
    myParamCollection.Add("@CategoryName", OleDbType.Char);
    myParamCollection.Add("@Description", OleDbType.Char);
    myParamCollection.Add("@Picture", OleDbType.Binary);
    string myParamNames = "";
    for (int i=0; i < myParamCollection.Count; i++)
       myParamNames += myParamCollection[i].ToString() + "\n";
    MessageBox.Show(myParamNames);
    myParamCollection.Clear();
 }

[C++] 
public:
void CreateOleDbParamColl(OleDbCommand* myCommand) {
    OleDbParameterCollection* myParamCollection = myCommand->Parameters;
    myParamCollection->Add(S"@CategoryName", OleDbType::Char);
    myParamCollection->Add(S"@Description", OleDbType::Char);
    myParamCollection->Add(S"@Picture", OleDbType::Binary);
    String* myParamNames = S"";
    for (int i=0; i < myParamCollection->Count; i++)
       myParamNames = String::Concat( myParamNames, myParamCollection->Item[i], S"\n" );
    MessageBox::Show(myParamNames);
    myParamCollection->Clear();
 }

[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

See Also

OleDbParameterCollection Class | OleDbParameterCollection Members | System.Data.OleDb Namespace

Show:
© 2014 Microsoft