MySqlParameterCollection Class

MySQL Connector/Net

MySqlParameterCollection Class
Represents a collection of parameters relevant to a MySqlCommand as well as their respective mappings to columns in a DataSet. This class cannot be inherited.
Inheritance Hierarchy
SystemObject  SystemMarshalByRefObject
    System.Data.CommonDbParameterCollection
      MySql.Data.MySqlClientMySqlParameterCollection

Namespace: MySql.Data.MySqlClient
Assembly: MySql.Data (in MySql.Data.dll) Version: 6.9.9
Syntax
public sealed class MySqlParameterCollection : DbParameterCollection
Public NotInheritable Class MySqlParameterCollection
	Inherits DbParameterCollection
public ref class MySqlParameterCollection sealed : public DbParameterCollection
[<SealedAttribute>]
type MySqlParameterCollection =  
    class
        inherit DbParameterCollection
    end

The MySqlParameterCollection type exposes the following members.

Properties
  NameDescription
Public propertyCount
Gets the number of MySqlParameter objects in the collection.
(Overrides DbParameterCollectionCount.)
Public propertyIsFixedSize
Gets a value that indicates whether the MySqlParameterCollection has a fixed size.
(Overrides DbParameterCollectionIsFixedSize.)
Public propertyIsReadOnly
Gets a value that indicates whether the MySqlParameterCollection is read-only.
(Overrides DbParameterCollectionIsReadOnly.)
Public propertyIsSynchronized
Gets a value that indicates whether the MySqlParameterCollection is synchronized.
(Overrides DbParameterCollectionIsSynchronized.)
Public propertyItemInt32
Gets the MySqlParameter at the specified index.
Public propertyItemString
Gets the MySqlParameter with the specified name.
Public propertySyncRoot
Gets an object that can be used to synchronize access to the MySqlParameterCollection.
(Overrides DbParameterCollectionSyncRoot.)
Top
Methods
  NameDescription
Public methodAdd(Object)
Adds the specified MySqlParameter object to the MySqlParameterCollection.
(Overrides DbParameterCollectionAdd(Object).)
Public methodAdd(MySqlParameter)
Adds the specified MySqlParameter object to the MySqlParameterCollection.
Public methodAdd(String, MySqlDbType)
Adds a MySqlParameter to the MySqlParameterCollection given the parameter name and the data type.
Public methodAdd(String, Object) Obsolete.
Adds a MySqlParameter to the MySqlParameterCollection given the specified parameter name and value.
Public methodAdd(String, MySqlDbType, Int32)
Adds a MySqlParameter to the MySqlParameterCollection with the parameter name, the data type, and the column length.
Public methodAdd(String, MySqlDbType, Int32, String)
Adds a MySqlParameter to the MySqlParameterCollection with the parameter name, the data type, the column length, and the source column name.
Public methodAddRange
Adds an array of values to the end of the MySqlParameterCollection.
(Overrides DbParameterCollectionAddRange(Array).)
Public methodAddWithValue
Public methodClear
Removes all items from the collection.
(Overrides DbParameterCollectionClear.)
Public methodContains(Object)
Gets a value indicating whether a MySqlParameter exists in the collection.
(Overrides DbParameterCollectionContains(Object).)
Public methodContains(String)
Gets a value indicating whether a MySqlParameter with the specified parameter name exists in the collection.
(Overrides DbParameterCollectionContains(String).)
Public methodCopyTo
Copies MySqlParameter objects from the MySqlParameterCollection to the specified array.
(Overrides DbParameterCollectionCopyTo(Array, Int32).)
Public methodCreateObjRef
Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
(Inherited from MarshalByRefObject.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetEnumerator
Returns an enumerator that iterates through the MySqlParameterCollection.
(Overrides DbParameterCollectionGetEnumerator.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetLifetimeService
Retrieves the current lifetime service object that controls the lifetime policy for this instance.
(Inherited from MarshalByRefObject.)
Protected methodGetParameter(Int32) (Overrides DbParameterCollectionGetParameter(Int32).)
Protected methodGetParameter(String)
Retrieve the parameter with the given name.
(Overrides DbParameterCollectionGetParameter(String).)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIndexOf(Object)
Gets the location of a MySqlParameter in the collection.
(Overrides DbParameterCollectionIndexOf(Object).)
Public methodIndexOf(String)
Gets the location of the MySqlParameter in the collection with a specific parameter name.
(Overrides DbParameterCollectionIndexOf(String).)
Public methodInitializeLifetimeService
Obtains a lifetime service object to control the lifetime policy for this instance.
(Inherited from MarshalByRefObject.)
Public methodInsert
Inserts a MySqlParameter into the collection at the specified index.
(Overrides DbParameterCollectionInsert(Int32, Object).)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodMemberwiseClone(Boolean)
Creates a shallow copy of the current MarshalByRefObject object.
(Inherited from MarshalByRefObject.)
Public methodRemove
Removes the specified MySqlParameter from the collection.
(Overrides DbParameterCollectionRemove(Object).)
Public methodRemoveAt(Int32)
Removes the specified MySqlParameter from the collection using a specific index.
(Overrides DbParameterCollectionRemoveAt(Int32).)
Public methodRemoveAt(String)
Removes the specified MySqlParameter from the collection using the parameter name.
(Overrides DbParameterCollectionRemoveAt(String).)
Protected methodSetParameter(Int32, DbParameter) (Overrides DbParameterCollectionSetParameter(Int32, DbParameter).)
Protected methodSetParameter(String, DbParameter) (Overrides DbParameterCollectionSetParameter(String, DbParameter).)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Remarks
The number of the parameters in the collection must be equal to the number of parameter placeholders within the command text, or an exception will be generated.
Examples
The following example creates multiple instances of MySqlParameter through the MySqlParameterCollection collection within the MySqlDataAdapter. These parameters are used to select data within the data source and place the data in the DataSet. This code assumes that a DataSet and a MySqlDataAdapter have already been created with the appropriate schema, commands, and connection.
public void AddSqlParameters()
{
// ...
// create myDataSet and myDataAdapter
// ...

myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", MySqlDbType.VarChar, 80).Value = "toasters";
myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", MySqlDbType.Long).Value = 239;
myDataAdapter.Fill(myDataSet);

}
Public Sub AddParameters()
' ...
' create myDataSet and myDataAdapter
' ...
myDataAdapter.SelectCommand.Parameters.Add("@CategoryName", MySqlDbType.VarChar, 80).Value = "toasters"
myDataAdapter.SelectCommand.Parameters.Add("@SerialNum", MySqlDbType.Long).Value = 239

myDataAdapter.Fill(myDataSet)
End Sub 'AddSqlParameters

No code example is currently available or this language may not be supported.

No code example is currently available or this language may not be supported.

See Also