Add(String,Object) Method
The name of the parameter to add (without the database-specific bind variable prefix such as @ for Microsoft SQL Server or : for Oracle)
The value of the parameter that will be passed to the database as part of the query
Adds a parameter to this collection for use as a bind variable in the SQL statement.
Syntax
'Declaration
Public Overloads Function Add( _
ByVal _name_ As String, _
ByVal _value_ As Object _
) As Integer
public int Add(
string _name_,
object _value_
)
Parameters
name
The name of the parameter to add (without the database-specific bind variable prefix such as @ for Microsoft SQL Server or : for Oracle)
value
The value of the parameter that will be passed to the database as part of the query
Return Value
The index in the collection at which the new parameters was added.
Remarks
This method will create a new instance of an IDataParameter of the underlying type that matches the data provider specified by the default DbProvider, or the one passed into the constructor. For example, if the data provider is Microsoft SQL Server, this method will add a SqlParameter to the collection.
The name parameter should be a simple name without any database-specific prefix such as "@" for SQL Server or ":" for Oracle. The SqlHelper will take care of adding the specific prefix.
The rules for the value parameter are dictated by the underlying data provider type. In general, basic types will be supported without problems, but database-specific values such as large binary arrays or text fields might require extra preparation. Consult the database vendor's documentation or the .NET Framework SDK documentation for these special considerations.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server family
Reference
DataParameterCollection Class
DataParameterCollection Members
Overload List