dotConnect for MySQL Documentation
Devart.Data.MySql Namespace / MySqlParameterCollection Class / Add Method / Add(String,MySqlType) Method
The name of the parameter.
One of the MySqlType values.
Example

In This Topic
    Add(String,MySqlType) Method
    In This Topic
    Adds a MySqlParameter to the MySqlParameterCollection given the parameter name and data type.
    Syntax
    'Declaration
     
    Public Overloads Function Add( _
       ByVal parameterName As String, _
       ByVal type As MySqlType _
    ) As MySqlParameter
    public MySqlParameter Add( 
       string parameterName,
       MySqlType type
    )

    Parameters

    parameterName
    The name of the parameter.
    type
    One of the MySqlType values.

    Return Value

    The new MySqlParameter object.
    Example
    The following example creates a MySqlParameterCollection, adds instances of MySqlParameter to the collection, and returns a reference to the new MySqlParameter.
    public void CreateMySqlParamColl(MySqlConnection myConn) {
      MySqlCommand myCommand = new MySqlCommand("SELECT * FROM Test.Dept WHERE DeptNo = :DeptNo", myConn);
      MySqlParameterCollection myParamCollection = myCommand.Parameters;
      object myParm = new MySqlParameter("DeptNo", MySqlType.Int);
      int pIndex = myParamCollection.Add(myParm);
    }
    Public Sub CreateMySqlParamColl(myConn As MySqlConnection)
      Dim myCommand As MySqlCommand = New MySqlCommand("SELECT * FROM Test.Dept WHERE DeptNo = :DeptNo", myConn)
      Dim myParamCollection As MySqlParameterCollection = myCommand.Parameters
      Dim myParm As Object = New MySqlParameter("DeptNo", MySqlType.Int)
      Dim pIndex As Integer = myParamCollection.Add(myParm)
    End Sub
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also