OdbcParameter.DbType Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the DbType of the parameter.
public:
property System::Data::DbType DbType { System::Data::DbType get(); void set(System::Data::DbType value); };
public:
virtual property System::Data::DbType DbType { System::Data::DbType get(); void set(System::Data::DbType value); };
[System.ComponentModel.Browsable(false)]
public System.Data.DbType DbType { get; set; }
public override System.Data.DbType DbType { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.DbType : System.Data.DbType with get, set
member this.DbType : System.Data.DbType with get, set
Public Property DbType As DbType
Public Overrides Property DbType As DbType
Property Value
One of the DbType values. The default is String.
Implements
- Attributes
Exceptions
The property was not set to a valid DbType.
Examples
The following example calls a Stored Procedure with three parameters using the ODBC managed provider.
public void CreateMyProc(OdbcConnection connection)
{
OdbcCommand command = connection.CreateCommand();
command.CommandText = "{ call MyProc(?,?,?) }";
OdbcParameter param = new OdbcParameter();
param.DbType = DbType.Int32;
param.Value = 1;
command.Parameters.Add(param);
param = new OdbcParameter();
param.DbType = DbType.Decimal;
param.Value = 1;
command.Parameters.Add(param);
param = new OdbcParameter();
param.DbType = DbType.Decimal;
param.Value = 1;
command.Parameters.Add(param);
command.ExecuteNonQuery();
}
Public Sub CreateMyProc(ByVal connection As OdbcConnection)
Dim command As OdbcCommand = connection.CreateCommand()
Command.CommandText = "{ call MyProc(?,?,?) }"
Dim param As New OdbcParameter()
param.DbType = DbType.Int32
param.Value = 1
command.Parameters.Add(param)
param = New OdbcParameter()
param.DbType = DbType.Decimal
param.Value = 1
command.Parameters.Add(param)
param = New OdbcParameter()
param.DbType = DbType.Decimal
param.Value = 1
command.Parameters.Add(param)
command.ExecuteNonQuery()
End Sub
Remarks
The OdbcType and DbType are linked. Therefore, setting the DbType changes the OdbcType to a supporting OdbcType.
For a list of the supported data types, see the appropriate OdbcType member. For more information, see DataAdapter Parameters.
Note
Object is not supported by the Microsoft .NET Framework Data Provider for ODBC.