MySqlParameterCollection Class

MySQL Connector/Net

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.

Namespace:  MySql.Data.MySqlClient
Assembly:  MySql.Data (in MySql.Data.dll) Version: 6.2.2.0

Syntax

C#
public sealed class MySqlParameterCollection : DbParameterCollection
Visual Basic (Declaration)
Public NotInheritable Class MySqlParameterCollection _
	Inherits DbParameterCollection
Visual C++
public ref class MySqlParameterCollection sealed : public DbParameterCollection

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.
CopyVB.NET
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
CopyC#
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);

}

Inheritance Hierarchy

System..::.Object
  System..::.MarshalByRefObject
    System.Data.Common..::.DbParameterCollection
      MySql.Data.MySqlClient..::.MySqlParameterCollection

See Also