dotConnect for PostgreSQL Documentation
Devart.Data.PostgreSql Namespace / PgSqlParameterCollection Class / Add Method / Add(String,PgSqlType) Method
The name of the parameter.
One of the PgSqlType values.
Example

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

    Parameters

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

    Return Value

    The new PgSqlParameter object.
    Example
    The following example creates a PgSqlParameterCollection, adds instances of PgSqlParameter to the collection, and returns a reference to the new PgSqlParameter.
    public void CreatePgSqlParamColl(PgSqlConnection myConn) {
      PgSqlCommand pgCommand = new PgSqlCommand("SELECT * FROM Test.Dept WHERE DeptNo = :DeptNo", myConn);
      PgSqlParameterCollection myParamCollection = pgCommand.Parameters;
      object myParm = new PgSqlParameter("DeptNo", PgSqlType.Int);
      int pIndex = myParamCollection.Add(myParm);
    }
    Public Sub CreatePgSqlParamColl(myConn As PgSqlConnection)
      Dim pgCommand As PgSqlCommand = New PgSqlCommand("SELECT * FROM Test.Dept WHERE DeptNo = :DeptNo", myConn)
      Dim myParamCollection As PgSqlParameterCollection = pgCommand.Parameters
      Dim myParm As Object = New PgSqlParameter("DeptNo", PgSqlType.Int)
      Dim pIndex As Integer = myParamCollection.Add(myParm)
    End Sub
    See Also