System.Data.SqlClient Namespace SqlParameterCollection Class
Adds an SqlParameter with the specified name, data type, and column width to the parameters collection.
[ VB ]
Overloads Public Function Add ( _
ByVal parameterName As String, _
ByVal oleDbType As SqlDbType, _
ByVal size As Integer, _
) As SqlParameter
[ C# ]
public SqlParameter Add (
string parameterName,
SqlDbType oleDbType,
int size
);
[ C++ ]
public: SqlParameter* Add (
String* parameterName,
SqlDbType oleDbType,
int size
);
[ JScript ]
public function Add (
parameterName : String,
oleDbType : SqlDbType,
size : int
) : SqlParameter;
- parameterName
- The name of the parameter.
- oleDbType
- One of the SqlDbType values.
- size
- The width of the column.
The newly created SqlParameter.
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;
SqlParameter myParam = myParams.Add ( new SqlParameter (
"@CustomerID", SqlDbType.VarChar, 5 ) );
}
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 SqlParameter = myParams.Add ( New SqlParameter ( _
"@CustomerID", SqlDbType.VarChar, 5 ) )
End Sub |
|
C# |
VB |
SqlParameterCollection Members SqlParameterCollection.Add Overload List SqlDbType ParameterName Size