OdbcParameter 构造函数

定义

初始化 OdbcParameter 类的新实例。Initializes a new instance of the OdbcParameter class.

重载

OdbcParameter()

初始化 OdbcParameter 类的新实例。Initializes a new instance of the OdbcParameter class.

OdbcParameter(String, OdbcType)

初始化使用参数名称和数据类型的 OdbcParameter 类的新实例。Initializes a new instance of the OdbcParameter class that uses the parameter name and data type.

OdbcParameter(String, Object)

初始化使用参数名称和 OdbcParameter 对象的 OdbcParameter 类的新实例。Initializes a new instance of the OdbcParameter class that uses the parameter name and an OdbcParameter object.

OdbcParameter(String, OdbcType, Int32)

初始化使用参数名称、数据类型和长度的 OdbcParameter 类的新实例。Initializes a new instance of the OdbcParameter class that uses the parameter name, data type, and length.

OdbcParameter(String, OdbcType, Int32, String)

初始化使用参数名称、数据类型、长度和源列名称的 OdbcParameter 类的新实例。Initializes a new instance of the OdbcParameter class that uses the parameter name, data type, length, and source column name.

OdbcParameter(String, OdbcType, Int32, ParameterDirection, Boolean, Byte, Byte, String, DataRowVersion, Object)

初始化 OdbcParameter 类的新实例,该类使用参数名称、数据类型、长度、源列名、参数方向、数值精度和其他属性。Initializes a new instance of the OdbcParameter class that uses the parameter name, data type, length, source column name, parameter direction, numeric precision, and other properties.

OdbcParameter(String, OdbcType, Int32, ParameterDirection, Byte, Byte, String, DataRowVersion, Boolean, Object)

初始化 OdbcParameter 类的新实例,该类使用参数名称、数据类型、长度、源列名、参数方向、数值精度和其他属性。Initializes a new instance of the OdbcParameter class that uses the parameter name, data type, length, source column name, parameter direction, numeric precision, and other properties.

OdbcParameter()

初始化 OdbcParameter 类的新实例。Initializes a new instance of the OdbcParameter class.

public:
 OdbcParameter();
public OdbcParameter ();
Public Sub New ()

示例

下面的示例创建一个 OdbcParameter 并设置其一些属性。The following example creates an OdbcParameter and sets some of its properties.

public void CreateOdbcParameter() 
{
   OdbcParameter parameter = new OdbcParameter();
   parameter.ParameterName = "Description";
   parameter.OdbcType = OdbcType.VarChar;
   parameter.Direction = ParameterDirection.Output;
   parameter.Size = 88;
}
Public Sub CreateOdbcParameter()
    Dim parameter As New OdbcParameter()
    parameter.ParameterName = "Description"
    parameter.OdbcType = OdbcType.VarChar
    parameter.Direction = ParameterDirection.Output
    parameter.Size = 88
End Sub 

注解

基本构造函数将所有字段初始化为其默认值。The base constructor initializes all fields to their default values.

另请参阅

OdbcParameter(String, OdbcType)

初始化使用参数名称和数据类型的 OdbcParameter 类的新实例。Initializes a new instance of the OdbcParameter class that uses the parameter name and data type.

public:
 OdbcParameter(System::String ^ name, System::Data::Odbc::OdbcType type);
public OdbcParameter (string name, System.Data.Odbc.OdbcType type);
new System.Data.Odbc.OdbcParameter : string * System.Data.Odbc.OdbcType -> System.Data.Odbc.OdbcParameter
Public Sub New (name As String, type As OdbcType)

参数

name
String

参数的名称。The name of the parameter.

type
OdbcType

OdbcType 值之一。One of the OdbcType values.

异常

参数 type 中提供的值不是有效的后端数据类型。The value supplied in the type parameter is an invalid back-end data type.

示例

下面的示例创建一个 OdbcParameter 并设置其一些属性。The following example creates an OdbcParameter and sets some of its properties.


public void CreateOdbcParameter() 
{
   OdbcParameter parameter = new OdbcParameter("Description",OdbcType.VarChar);
   parameter.Direction = ParameterDirection.Output;
   parameter.Size = 88;
}
Public Sub CreateOdbcParameter()
    Dim parameter As New OdbcParameter("Description", OdbcType.VarChar)
    parameter.Direction = ParameterDirection.Output
    parameter.Size = 88
End Sub 

另请参阅

OdbcParameter(String, Object)

初始化使用参数名称和 OdbcParameter 对象的 OdbcParameter 类的新实例。Initializes a new instance of the OdbcParameter class that uses the parameter name and an OdbcParameter object.

public:
 OdbcParameter(System::String ^ name, System::Object ^ value);
public OdbcParameter (string name, object value);
new System.Data.Odbc.OdbcParameter : string * obj -> System.Data.Odbc.OdbcParameter
Public Sub New (name As String, value As Object)

参数

name
String

参数的名称。The name of the parameter.

value
Object

一个 OdbcParameter 对象。An OdbcParameter object.

注解

使用 OdbcParameter 构造函数的此重载来指定整数参数值时,请务必小心。Use caution when you are using this overload of the OdbcParameter constructor to specify integer parameter values. 因为此重载接受 value 类型的 Object,所以当此值为零时,必须将整数值转换为 Object 类型,如下面的 C# 示例所示。Because this overload takes a value of type Object, you must convert the integral value to an Object type when the value is zero, as the following C# example demonstrates.

Parameter = new OdbcParameter("@pname", Convert.ToInt32(0));  

如果不执行此转换,编译器将假定您尝试调用 OdbcParameter.OdbcParameter 构造函数重载。If you do not perform this conversion, the compiler assumes that you are trying to call the OdbcParameter.OdbcParameter constructor overload.

另请参阅

OdbcParameter(String, OdbcType, Int32)

初始化使用参数名称、数据类型和长度的 OdbcParameter 类的新实例。Initializes a new instance of the OdbcParameter class that uses the parameter name, data type, and length.

public:
 OdbcParameter(System::String ^ name, System::Data::Odbc::OdbcType type, int size);
public OdbcParameter (string name, System.Data.Odbc.OdbcType type, int size);
new System.Data.Odbc.OdbcParameter : string * System.Data.Odbc.OdbcType * int -> System.Data.Odbc.OdbcParameter
Public Sub New (name As String, type As OdbcType, size As Integer)

参数

name
String

参数的名称。The name of the parameter.

type
OdbcType

OdbcType 值之一。One of the OdbcType values.

size
Int32

参数的长度。The length of the parameter.

异常

参数 type 中提供的值不是有效的后端数据类型。The value supplied in the type parameter is an invalid back-end data type.

示例

下面的示例创建一个 OdbcParameter 并设置其一些属性。The following example creates an OdbcParameter and sets some of its properties.


public void CreateOdbcParameter() 
{
   OdbcParameter parameter = new OdbcParameter("Description",OdbcType.VarChar,88);
   parameter.Direction = ParameterDirection.Output;
}
Public Sub CreateOdbcParameter()
    Dim parameter As New OdbcParameter("Description", OdbcType.VarChar, 88)
    parameter.Direction = ParameterDirection.Output
End Sub 

另请参阅

OdbcParameter(String, OdbcType, Int32, String)

初始化使用参数名称、数据类型、长度和源列名称的 OdbcParameter 类的新实例。Initializes a new instance of the OdbcParameter class that uses the parameter name, data type, length, and source column name.

public:
 OdbcParameter(System::String ^ name, System::Data::Odbc::OdbcType type, int size, System::String ^ sourcecolumn);
public OdbcParameter (string name, System.Data.Odbc.OdbcType type, int size, string sourcecolumn);
new System.Data.Odbc.OdbcParameter : string * System.Data.Odbc.OdbcType * int * string -> System.Data.Odbc.OdbcParameter
Public Sub New (name As String, type As OdbcType, size As Integer, sourcecolumn As String)

参数

name
String

参数的名称。The name of the parameter.

type
OdbcType

OdbcType 值之一。One of the OdbcType values.

size
Int32

参数的长度。The length of the parameter.

sourcecolumn
String

源列的名称。The name of the source column.

异常

参数 type 中提供的值不是有效的后端数据类型。The value supplied in the type parameter is an invalid back-end data type.

示例

下面的示例创建一个 OdbcParameter 并设置其一些属性。The following example creates an OdbcParameter and sets some of its properties.

public void CreateOdbcParameter() 
{
    OdbcParameter parameter = new OdbcParameter("Description",OdbcType.VarChar,
        88,"Description");
    parameter.Direction = ParameterDirection.Output;
}
Public Sub CreateOdbcParameter()
    Dim parameter As New OdbcParameter("Description", OdbcType.VarChar, 88, "Description")
    parameter.Direction = ParameterDirection.Output
End Sub 

另请参阅

OdbcParameter(String, OdbcType, Int32, ParameterDirection, Boolean, Byte, Byte, String, DataRowVersion, Object)

初始化 OdbcParameter 类的新实例,该类使用参数名称、数据类型、长度、源列名、参数方向、数值精度和其他属性。Initializes a new instance of the OdbcParameter class that uses the parameter name, data type, length, source column name, parameter direction, numeric precision, and other properties.

public:
 OdbcParameter(System::String ^ parameterName, System::Data::Odbc::OdbcType odbcType, int size, System::Data::ParameterDirection parameterDirection, bool isNullable, System::Byte precision, System::Byte scale, System::String ^ srcColumn, System::Data::DataRowVersion srcVersion, System::Object ^ value);
public OdbcParameter (string parameterName, System.Data.Odbc.OdbcType odbcType, int size, System.Data.ParameterDirection parameterDirection, bool isNullable, byte precision, byte scale, string srcColumn, System.Data.DataRowVersion srcVersion, object value);
new System.Data.Odbc.OdbcParameter : string * System.Data.Odbc.OdbcType * int * System.Data.ParameterDirection * bool * byte * byte * string * System.Data.DataRowVersion * obj -> System.Data.Odbc.OdbcParameter

参数

parameterName
String

参数的名称。The name of the parameter.

odbcType
OdbcType

OdbcType 值之一。One of the OdbcType values.

size
Int32

参数的长度。The length of the parameter.

parameterDirection
ParameterDirection

ParameterDirection 值之一。One of the ParameterDirection values.

isNullable
Boolean

如果字段的值可以为 null,则为 true;否则为 falsetrue if the value of the field can be null; otherwise false.

precision
Byte

所解析的 Value 的小数点左右两侧的总位数。The total number of digits to the left and right of the decimal point to which Value is resolved.

scale
Byte

所解析的 Value 的总小数位数。The total number of decimal places to which Value is resolved.

srcColumn
String

源列的名称。The name of the source column.

srcVersion
DataRowVersion

DataRowVersion 值之一。One of the DataRowVersion values.

value
Object

作为 Object 的值的 OdbcParameterAn Object that is the value of the OdbcParameter.

异常

参数 type 中提供的值不是有效的后端数据类型。The value supplied in the type parameter is an invalid back-end data type.

示例

下面的示例创建一个 OdbcParameter 并显示 ParameterNameThe following example creates an OdbcParameter and displays the ParameterName.

public void CreateOdbcParameter()
{
    OdbcParameter parameter = new OdbcParameter(
        "Description", OdbcType.VarChar, 11, 
        ParameterDirection.Output, true, 0, 0, "Description",
        DataRowVersion.Current, "garden hose");
    Console.WriteLine(parameter.ToString());
}
Public Sub CreateOdbcParameter()
    Dim parameter As New OdbcParameter("Description", OdbcType.VarChar, _
        11, ParameterDirection.Output, True, 0, 0, "Description", _
        DataRowVersion.Current, "garden hose")
    Console.WriteLine(parameter.ToString())
End Sub

另请参阅

OdbcParameter(String, OdbcType, Int32, ParameterDirection, Byte, Byte, String, DataRowVersion, Boolean, Object)

初始化 OdbcParameter 类的新实例,该类使用参数名称、数据类型、长度、源列名、参数方向、数值精度和其他属性。Initializes a new instance of the OdbcParameter class that uses the parameter name, data type, length, source column name, parameter direction, numeric precision, and other properties.

public:
 OdbcParameter(System::String ^ parameterName, System::Data::Odbc::OdbcType odbcType, int size, System::Data::ParameterDirection parameterDirection, System::Byte precision, System::Byte scale, System::String ^ sourceColumn, System::Data::DataRowVersion sourceVersion, bool sourceColumnNullMapping, System::Object ^ value);
public OdbcParameter (string parameterName, System.Data.Odbc.OdbcType odbcType, int size, System.Data.ParameterDirection parameterDirection, byte precision, byte scale, string sourceColumn, System.Data.DataRowVersion sourceVersion, bool sourceColumnNullMapping, object value);
new System.Data.Odbc.OdbcParameter : string * System.Data.Odbc.OdbcType * int * System.Data.ParameterDirection * byte * byte * string * System.Data.DataRowVersion * bool * obj -> System.Data.Odbc.OdbcParameter

参数

parameterName
String

参数的名称。The name of the parameter.

odbcType
OdbcType

OdbcType 值之一。One of the OdbcType values.

size
Int32

参数的长度。The length of the parameter.

parameterDirection
ParameterDirection

ParameterDirection 值之一。One of the ParameterDirection values.

precision
Byte

所解析的 Value 的小数点左右两侧的总位数。The total number of digits to the left and right of the decimal point to which Value is resolved.

scale
Byte

所解析的 Value 的总小数位数。The total number of decimal places to which Value is resolved.

sourceColumn
String

源列的名称。The name of the source column.

sourceVersion
DataRowVersion

DataRowVersion 值之一。One of the DataRowVersion values.

sourceColumnNullMapping
Boolean

如果对应的源列可为 null,则为 true;否则为 falsetrue if the corresponding source column is nullable; false if it is not.

value
Object

作为 Object 的值的 OdbcParameterAn Object that is the value of the OdbcParameter.

异常

参数 type 中提供的值不是有效的后端数据类型。The value supplied in the type parameter is an invalid back-end data type.

示例

下面的示例创建一个 OdbcParameter 并显示 ParameterNameThe following example creates an OdbcParameter and displays the ParameterName.

Public Sub CreateOdbcParameter()  
  Dim parameter As New OdbcParameter("Description", OdbcType.VarChar, 11, ParameterDirection.Output, True, 0, 0, "Description", DataRowVersion.Current, False, "garden hose")  
  MessageBox.Show(parameter.ToString())  
End Sub  
public void CreateOdbcParameter()   
{  
  OdbcParameter parameter = new OdbcParameter("Description",OdbcType.VarChar,  
              11,ParameterDirection.Output,true,0,0,"Description",  
              DataRowVersion.Current, false, "garden hose");  
  MessageBox.Show(parameter.ToString());  
}  

另请参阅

适用于