SqlParameter.DbType SqlParameter.DbType SqlParameter.DbType SqlParameter.DbType Property


Gets or sets the SqlDbType of the parameter.

 virtual property System::Data::DbType DbType { System::Data::DbType get(); void set(System::Data::DbType value); };
public override System.Data.DbType DbType { get; set; }
member this.DbType : System.Data.DbType with get, set
Public Overrides Property DbType As DbType

Property Value

One of the SqlDbType values. The default is NVarChar.



The following example creates a SqlParameter and sets some of its properties.

    private static void AddSqlParameter(SqlCommand command, 
        string paramValue)
        SqlParameter parameter = new SqlParameter(
            "@Description", SqlDbType.VarChar);
        parameter.Value = paramValue;
        parameter.IsNullable = true;

private static void SetParameterToNull(IDataParameter parameter)
    if (parameter.IsNullable)
        parameter.Value = DBNull.Value;
        throw new ArgumentException("Parameter provided is not nullable", "parameter");

 Private Sub AddSqlParameter(ByVal command As SqlCommand, _
     ByVal paramValue As String)

     Dim parameter As New SqlParameter( _
         "@Description", SqlDbType.NVarChar, 16)
     parameter.Value = paramValue
     parameter.IsNullable = True
 End Sub

 Private Shared Sub SetParameterToNull(parameter As IDataParameter)
     If parameter.IsNullable Then
  parameter.Value = DBNull.Value
         Throw New ArgumentException("Parameter provided is not nullable", "parameter")
     End If
End Sub


The SqlDbType and DbType are linked. Therefore, setting the DbType changes the SqlDbType to a supporting SqlDbType.

For a list of the supported data types, see the appropriate SqlDbType member. For more information, see DataAdapter Parameters.

Applies to

See also