System.Data.SqlClient Namespace SqlParameterCollection Class
Adds a new SqlParameter object to the parameters collection.
[ VB ]
Overloads Public Sub Add ( _
ByVal param As Object _
) As Integer
[ C# ]
public int object Add (
Object param
);
[ C++ ]
public: int Add (
Object* param
);
[ JScript ]
public function Add (
param : Object
) : int ;
- param
- The SqlParameter to add.
The index of the newly created SqlParameter.
IList.Add
The following example adds a new SqlParameter using this constructor.
public void CreateSqlParamColl ( SqlConnection myConn ) {
SqlCommand myCmd = new SqlCommand (
"SELECT * FROM Customers WHERE CustomerID = @CustomerID", myConn );
SqlParameterCollection myParams = myCmd.Parameters;
object myParam = new SqlParameter ( "@CustomerID", SqlDbType.VarChar ) );
int pIndex = myParams.Add ( myParam );
}
Public Sub CreateSqlParamColl ( myConn As SqlConnection )
Dim myCmd As New SqlCommand ( _
"SELECT * FROM Customers WHERE CustomerID = @CustomerID", myConn )
Dim myParams As SqlParameterCollection = myCmd.Parameters
Dim myParam As Object = New SqlParameter ( "@CustomerID", SqlDbType.VarChar ) )
Sim pIndex As Integer = myParams.Add ( myParam )
End Sub |
|
C# |
VB |
SqlParameterCollection Members SqlParameterCollection.Add Overload List