asp.net.ph

SqlParameterCollection.Add Method ( String, Object )

System.Data.SqlClient Namespace   SqlParameterCollection Class


Adds an SqlParameter with the specified name and value to the parameters collection.

[ VB ]
Overloads Public Function Add ( _
   ByVal parameterName As String, _
   ByVal value As Object _
) As SqlParameter

[ C# ]
public SqlParameter Add (
   string parameterName,
   Object value
);

[ C++ ]
public: SqlParameter* Add (
   String* parameterName,
   Object* value
);

[ JScript ]
public function Add (
   parameterName : String,
   value : Object
) : SqlParameter;

Parameters

parameterName
The name of the parameter.
value
The parameter's value.

Return Value

The newly created SqlParameter.

Remarks

When you specify an Object in the value parameter, the SqlDbType is inferred from the .NET Framework type of the Object.

Example

The following example adds a new SqlParameter using this constructor.

SqlCommand cmd = new SqlCommand ( null, conn );
cmd.CommandText = "Insert into Categories ( CategoryName ) values ( @CategoryName ) ";
cmd.Parameters.Add ( "@CategoryName", "Beverages" );
  C# VB

See Also

SqlParameterCollection Members   SqlParameterCollection.Add Overload List   Value Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

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

You can help support asp.net.ph