SqlParameterCollection Class
Assembly: System.Data (in system.data.dll)
'Declaration Public NotInheritable Class SqlParameterCollection Inherits DbParameterCollection 'Usage Dim instance As SqlParameterCollection
public final class SqlParameterCollection extends DbParameterCollection
public final class SqlParameterCollection extends DbParameterCollection
Not applicable.
If the command contains an ad hoc SQL statement, as opposed to a stored-procedure name, the number of the parameters in the collection must be equal to the number of parameter placeholders within the command text, or SQL Server raises an error. With a stored procedure, all the parameters declared in the stored procedure without a default value must be provided. Parameters declared with a default value are optional. This lets you specify a value other than the default.
The following example creates multiple instances of SqlParameter through the SqlParameterCollection collection. The parameters are used to select data within the data source and populate the DataSet. This code assumes that a DataSet and a SqlDataAdapter have already been created with the appropriate schema, commands, and connection.
Public Sub AddSqlParameters() ' ... ' create categoriesDataSet and categoriesAdapter ' ... categoriesAdapter.SelectCommand.Parameters.Add( _ "@CategoryName", SqlDbType.VarChar, 80).Value = "toasters" categoriesAdapter.SelectCommand.Parameters.Add( _ "@SerialNum", SqlDbType.Int).Value = 239 categoriesAdapter.Fill(categoriesDataSet) End Sub
System.MarshalByRefObject
System.Data.Common.DbParameterCollection
System.Data.SqlClient.SqlParameterCollection
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.