dotConnect for SQL Server Documentation
Devart.Data.SqlServer Namespace / SqlParameterCollection Class / Add Method / Add(String,SqlType) Method
The name of the parameter.
One of the SqlType values.
Example

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

    Parameters

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

    Return Value

    The new SqlParameter object.
    Example
    The following example creates a SqlParameterCollection, adds instances of SqlParameter to the collection, and returns a reference to the new SqlParameter.
    public void CreateSqlParamColl(SqlConnection myConn) {
      SqlCommand myCommand = new SqlCommand("SELECT * FROM Test.Dept WHERE DeptNo = :DeptNo", myConn);
      SqlParameterCollection myParamCollection = myCommand.Parameters;
      object myParm = new SqlParameter("DeptNo", SqlType.Int);
      int pIndex = myParamCollection.Add(myParm);
    }
    Public Sub CreateSqlParamColl(myConn As SqlConnection)
      Dim myCommand As SqlCommand = New SqlCommand("SELECT * FROM Test.Dept WHERE DeptNo = :DeptNo", myConn)
      Dim myParamCollection As SqlParameterCollection = myCommand.Parameters
      Dim myParm As Object = New SqlParameter("DeptNo", SqlType.Int)
      Dim pIndex As Integer = myParamCollection.Add(myParm)
    End Sub
    See Also