This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Download Microsoft Edge
More info about Internet Explorer and Microsoft Edge
public ref class SqlParameter sealed : System::Data::Common::DbParameter, ICloneable
public ref class SqlParameter sealed : System::Data::Common::DbParameter
public ref class SqlParameter sealed : MarshalByRefObject, ICloneable, System::Data::IDbDataParameter
public sealed class SqlParameter : System.Data.Common.DbParameter, ICloneable
[System.ComponentModel.TypeConverter(typeof(System.Data.SqlClient.SqlParameter+SqlParameterConverter))]
public sealed class SqlParameter : System.Data.Common.DbParameter, ICloneable
public sealed class SqlParameter : System.Data.Common.DbParameter
[System.ComponentModel.TypeConverter(typeof(System.Data.SqlClient.SqlParameterConverter))]
public sealed class SqlParameter : MarshalByRefObject, ICloneable, System.Data.IDbDataParameter
[System.ComponentModel.TypeConverter("System.Data.SqlClient.SqlParameter+SqlParameterConverter, System.Data, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
public sealed class SqlParameter : System.Data.Common.DbParameter, ICloneable
[System.ComponentModel.TypeConverter("System.Data.SqlClient.SqlParameter+SqlParameterConverter, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
public sealed class SqlParameter : System.Data.Common.DbParameter, ICloneable
type SqlParameter = class
inherit DbParameter
interface ICloneable
[<System.ComponentModel.TypeConverter(typeof(System.Data.SqlClient.SqlParameter+SqlParameterConverter))>]
type SqlParameter = class
inherit DbParameter
interface ICloneable
type SqlParameter = class
inherit DbParameter
[<System.ComponentModel.TypeConverter(typeof(System.Data.SqlClient.SqlParameterConverter))>]
type SqlParameter = class
inherit MarshalByRefObject
interface IDbDataParameter
interface IDataParameter
interface ICloneable
[<System.ComponentModel.TypeConverter(typeof(System.Data.SqlClient.SqlParameter+SqlParameterConverter))>]
type SqlParameter = class
inherit DbParameter
interface IDbDataParameter
interface IDataParameter
interface ICloneable
[<System.ComponentModel.TypeConverter("System.Data.SqlClient.SqlParameter+SqlParameterConverter, System.Data, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")>]
type SqlParameter = class
inherit DbParameter
interface IDbDataParameter
interface IDataParameter
interface ICloneable
[<System.ComponentModel.TypeConverter("System.Data.SqlClient.SqlParameter+SqlParameterConverter, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")>]
type SqlParameter = class
inherit DbParameter
interface IDbDataParameter
interface IDataParameter
interface ICloneable
Public NotInheritable Class SqlParameter
Inherits DbParameter
Implements ICloneable
Public NotInheritable Class SqlParameter
Inherits DbParameter
Public NotInheritable Class SqlParameter
Inherits MarshalByRefObject
Implements ICloneable, IDbDataParameter
Inheritance
SqlParameter
Examples
The following example creates multiple instances of
SqlParameter
through the
SqlParameterCollection
collection within the
SqlDataAdapter
. These parameters are used to select data from the data source and put the data in the
DataSet
. This example assumes that a
DataSet
and a
SqlDataAdapter
have already been created by using the appropriate schema, commands, and connection. For more information and additional examples on using parameters, see
Retrieving and Modifying Data in ADO.NET
and
Configuring Parameters and Parameter Data Types
.
public void 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);
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
Parameter names are not case sensitive.
Nameless, also called ordinal, parameters are not supported by the .NET Framework Data Provider for SQL Server.
For more information, along with additional sample code demonstrating how to use parameters, see
Commands and Parameters
.
SqlParameter(String, SqlDbType, Int32, ParameterDirection, Byte, Byte, String, DataRowVersion, Boolean, Object, String, String, String)
Initializes a new instance of the
SqlParameter
class that uses the parameter name, the type of the parameter, the length of the parameter the direction, the precision, the scale, the name of the source column, one of the
DataRowVersion
values, a Boolean for source column mapping, the value of the
SqlParameter
, the name of the database where the schema collection for this XML instance is located, the owning relational schema where the schema collection for this XML instance is located, and the name of the schema collection for this parameter.
Enforces encryption of a parameter when using
Always Encrypted
. If SQL Server informs the driver that the parameter does not need to be encrypted, the query using the parameter will fail. This property provides additional protection against security attacks that involve a compromised SQL Server providing incorrect encryption metadata to the client, which may lead to data disclosure.
Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
(Inherited from
MarshalByRefObject
)
Obsolete.
Retrieves the current lifetime service object that controls the lifetime policy for this instance.
(Inherited from
MarshalByRefObject
)
Obsolete.
Obtains a lifetime service object to control the lifetime policy for this instance.
(Inherited from
MarshalByRefObject
)