OdbcParameter.DbType 属性

定义

获取或设置参数的 DbTypeGets or sets the DbType of the parameter.

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

属性值

DbType 值之一。One of the DbType values. 默认为 StringThe default is String.

实现

属性

异常

该属性未设置为有效的 DbTypeThe property was not set to a valid DbType.

示例

下面的示例使用 ODBC 托管提供程序调用带有三个参数的存储过程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

注解

OdbcTypeDbType 已链接。The OdbcType and DbType are linked. 因此,设置 DbType 会将 OdbcType 更改为支持的 OdbcTypeTherefore, setting the DbType changes the OdbcType to a supporting OdbcType.

有关支持的数据类型的列表,请参阅相应的 OdbcType 成员。For a list of the supported data types, see the appropriate OdbcType member. 有关详细信息,请参阅DataAdapter 参数For more information, see DataAdapter Parameters.

备注

适用于 ODBC 的 Microsoft .NET Framework 数据提供程序不支持 ObjectObject is not supported by the Microsoft .NET Framework Data Provider for ODBC.

适用于

另请参阅