dotConnect for SQL Server Documentation
Devart.Data.SqlServer Namespace / SqlParameterCollection Class / Add Method / Add(String,SqlType,Int32) Method
The name of the parameter.
One of the SqlType values.
The maximum size, in bytes, of the data the parameter can contain.
Example

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

    Parameters

    parameterName
    The name of the parameter.
    dbType
    One of the SqlType values.
    size
    The maximum size, in bytes, of the data the parameter can contain.

    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;
      SqlParameter myNewParameter = myParamCollection.Add("DeptNo", SqlType.Int, 40);
    }
    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 myNewParameter As SqlParameter = myParamCollection.Add("DeptNo", SqlType.Int, 40)
    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