asp.net.ph

SqlParameterCollection.Add Method

System.Data.SqlClient Namespace   SqlParameterCollection Class


Adds an SqlParameter to the parameters collection.

Overload List

1. Adds a new SqlParameter object to the parameters collection.

2. Adds a specified SqlParameter object to the parameters collection.

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

4. Adds an SqlParameter with the specified name and data type to the parameters collection.

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

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


Example

The following example adds a new SqlParameter.

NOTE: This example shows how to use one of the overloaded versions of Add. For other examples that may be available, see the individual overload topics.

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 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