asp.net.ph

SqlParameterCollection.Add Method ( String, SqlDbType, Int32, String )

System.Data.SqlClient Namespace   SqlParameterCollection Class


Adds an SqlParameter with the specified name, data type, column width, and source column name to the parameters collection.

[ VB ]
Overloads Public Function Add ( _
   ByVal parameterName As String, _
   ByVal oleDbType As SqlDbType, _
   ByVal size As Integer, _
   ByVal srcColumn As String, _
) As SqlParameter

[ C# ]
public SqlParameter Add (
   string parameterName,
   SqlDbType oleDbType,
   int size,
   string srcColumn
);

[ C++ ]
public: SqlParameter* Add (
   String* parameterName,
   SqlDbType oleDbType,
   int size,
   String* srcColumn
);

[ JScript ]
public function Add (
   parameterName : String,
   oleDbType : SqlDbType,
   size : int,
   srcColumn : String
) : SqlParameter;

Parameters

parameterName
The name of the parameter.
oleDbType
One of the SqlDbType values.
size
The width of the column.
srcColumn
The name of the source column.

Return Value

The newly created SqlParameter.

Example

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, "CustomerID" ) );
}
  C# VB

See Also

SqlParameterCollection Members   SqlParameterCollection.Add Overload List   SqlDbType   ParameterName   Size   SourceColumn Skip Navigation Links




Previous page Back to top Next page

Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note