SqlMetaData SqlMetaData SqlMetaData SqlMetaData Constructors

Definition

Overloads

SqlMetaData(String, SqlDbType) SqlMetaData(String, SqlDbType) SqlMetaData(String, SqlDbType) SqlMetaData(String, SqlDbType)

使用指定的列名称和类型初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name and type.

SqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type, Boolean, Boolean, SortOrder, Int32)

使用指定的列名称、类型、最大长度、精度、小数位数、区域设置 ID、比较选项和用户定义的类型 (UDT) 初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, type, maximum length, precision, scale, locale ID, compare options, and user-defined type (UDT). 这种形式的构造函数通过允许指定表值参数中的列是否唯一、列的排序顺序和列排序的序号,支持表值参数。 This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.

SqlMetaData(String, SqlDbType, String, String, String, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, String, String, String, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, String, String, String, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, String, String, String, Boolean, Boolean, SortOrder, Int32)

使用指定的列名称、数据库名称、所属架构、对象名称和默认服务器初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, database name, owning schema, object name, and default server. 这种形式的构造函数通过允许指定表值参数中的列是否唯一、列的排序顺序和列排序的序号,支持表值参数。 This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.

SqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions, Boolean, Boolean, SortOrder, Int32)

使用指定的列名称、类型、最大长度、区域设置、比较选项和服务器默认值初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, type, maximum length, locale, compare options, and server default. 这种形式的构造函数通过允许指定表值参数中的列是否唯一、列的排序顺序和列排序的序号,支持表值参数。 This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.

SqlMetaData(String, SqlDbType, Type, String, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Type, String, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Type, String, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Type, String, Boolean, Boolean, SortOrder, Int32)

使用指定的列名称、类型、用户定义的类型、SQL Server 类型和服务器默认值初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, type, user-defined type, SQL Server type, and server default. 这种形式的构造函数通过允许指定表值参数中的列是否唯一、列的排序顺序和列排序的序号,支持表值参数。 This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.

SqlMetaData(String, SqlDbType, Byte, Byte, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Byte, Byte, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Byte, Byte, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Byte, Byte, Boolean, Boolean, SortOrder, Int32)

使用指定的列名称、类型、精度、小数位数和服务器默认值初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, type, precision, scale, and server default. 这种形式的构造函数通过允许指定表值参数中的列是否唯一、列的排序顺序和列排序的序号,支持表值参数。 This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.

SqlMetaData(String, SqlDbType, Int64, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Int64, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Int64, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Int64, Boolean, Boolean, SortOrder, Int32)

使用指定的列名称、类型、最大长度和服务器默认值初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, type, maximum length, and server default. 这种形式的构造函数通过允许指定表值参数中的列是否唯一、列的排序顺序和列排序的序号,支持表值参数。 This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.

SqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type) SqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type) SqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type) SqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type)

使用指定的列名称、类型、最大长度、精度、小数位数、区域设置 ID、比较选项和用户定义的类型 (UDT) 初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, type, maximum length, precision, scale, locale ID, compare options, and user-defined type (UDT).

SqlMetaData(String, SqlDbType, String, String, String) SqlMetaData(String, SqlDbType, String, String, String) SqlMetaData(String, SqlDbType, String, String, String) SqlMetaData(String, SqlDbType, String, String, String)

使用指定的列名称、类型、数据库名称、所属架构和对象名称初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, type, database name, owning schema, and object name.

SqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions) SqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions) SqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions) SqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions)

使用指定的列名称、类型、最大长度、区域设置和比较选项初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, type, maximum length, locale, and compare options.

SqlMetaData(String, SqlDbType, Type, String) SqlMetaData(String, SqlDbType, Type, String) SqlMetaData(String, SqlDbType, Type, String) SqlMetaData(String, SqlDbType, Type, String)

使用指定的列名称、用户定义的类型 (UDT) 和 SQLServer 类型初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, user-defined type (UDT), and SQLServer type.

SqlMetaData(String, SqlDbType, Byte, Byte) SqlMetaData(String, SqlDbType, Byte, Byte) SqlMetaData(String, SqlDbType, Byte, Byte) SqlMetaData(String, SqlDbType, Byte, Byte)

使用指定的列名称、类型、精度和小数位数初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, type, precision, and scale.

SqlMetaData(String, SqlDbType, Type) SqlMetaData(String, SqlDbType, Type) SqlMetaData(String, SqlDbType, Type) SqlMetaData(String, SqlDbType, Type)

使用指定的列名称、类型和用户定义的类型 (UDT) 初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, type, and user-defined type (UDT).

SqlMetaData(String, SqlDbType, Int64) SqlMetaData(String, SqlDbType, Int64) SqlMetaData(String, SqlDbType, Int64) SqlMetaData(String, SqlDbType, Int64)

使用指定的列名称、类型和最大长度初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, type, and maximum length.

SqlMetaData(String, SqlDbType, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Boolean, Boolean, SortOrder, Int32)

使用指定的列名称和默认服务器初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, and default server. 这种形式的构造函数通过允许指定表值参数中的列是否唯一、列的排序顺序和列排序的序号,支持表值参数。 This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.

SqlMetaData(String, SqlDbType) SqlMetaData(String, SqlDbType) SqlMetaData(String, SqlDbType) SqlMetaData(String, SqlDbType)

使用指定的列名称和类型初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name and type.

public:
 SqlMetaData(System::String ^ name, System::Data::SqlDbType dbType);
public SqlMetaData (string name, System.Data.SqlDbType dbType);
new Microsoft.SqlServer.Server.SqlMetaData : string * System.Data.SqlDbType -> Microsoft.SqlServer.Server.SqlMetaData
Public Sub New (name As String, dbType As SqlDbType)

参数

name
String String String String

列的名称。 The name of the column.

dbType
SqlDbType SqlDbType SqlDbType SqlDbType

参数或列的 SQL Server 类型。 The SQL Server type of the parameter or column.

Exceptions

不允许的 SqlDbType 作为 dbType 传递给了构造函数。 A SqlDbType that is not allowed was passed to the constructor as dbType.

Examples

下面的示例创建一个新SqlMetaData通过指定列名称和列数据类型的对象SqlDbTypeIntThe following example creates a new SqlMetaData object by specifying the column name and a column data type of SqlDbType.Int.

public static void CreateSqlMetaData2()
{
   SqlMetaData columnInfo;
   columnInfo = new SqlMetaData("Column2", SqlDbType.Int);
}
Public Shared Sub CreateSqlMetaData2()

   Dim columnInfo As SqlMetaData
   columnInfo = new SqlMetaData("ColumnName", SqlDbType.Int)

End Sub

Remarks

仅以下允许传递给构造函数、 作为dbType: BitBigIntDateTimeDecimalFloatIntMoneyNumericSmallDateTimeSmallInt, SmallMoney, TimeStamp, TinyInt, UniqueIdentifier, Xml.Only the following are allowed to be passed to the constructor as dbType: Bit, BigInt, DateTime, Decimal, Float, Int, Money, Numeric, SmallDateTime, SmallInt, SmallMoney, TimeStamp, TinyInt, UniqueIdentifier, Xml.

以下是分配给默认值dbType,具体取决于SqlDbType( XmlSchemaCollectionDatabaseXmlSchemaCollectionNameXmlSchemaCollectionOwningSchema,并且Type属性设置为null):The following are the default values assigned to dbType, depending on the SqlDbType (the XmlSchemaCollectionDatabase, XmlSchemaCollectionName, XmlSchemaCollectionOwningSchema, and Type properties are set to null):

SqlDbTypeSqlDbType 最大长度Maximum length 精度Precision 缩放Scale 区域设置Locale 比较选项Compare options
Bit 11 11 00 00 None
BigInt 88 1919 00 00 None
DateTime 88 2323 33 00 None
Decimal 99 1818 00 00 None
Float 88 5353 00 00 None
Int 44 1010 00 00 None
Money 88 1919 44 00 None
Numeric 99 1818 00 00 None
SmallDateTime 44 1616 00 00 None
SmallInt 22 55 00 00 None
SmallMoney 44 1010 44 00 None
TimeStamp 88 00 00 00 None
TinyInt 11 33 00 00 None
UniqueIdentifier 1616 00 00 00 None
Xml 最大值 (-1)Max (-1) 00 00 00 IgnoreCase, IgnoreKanaType, IgnoreWidthIgnoreCase, IgnoreKanaType, IgnoreWidth

SqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type, Boolean, Boolean, SortOrder, Int32)

使用指定的列名称、类型、最大长度、精度、小数位数、区域设置 ID、比较选项和用户定义的类型 (UDT) 初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, type, maximum length, precision, scale, locale ID, compare options, and user-defined type (UDT). 这种形式的构造函数通过允许指定表值参数中的列是否唯一、列的排序顺序和列排序的序号,支持表值参数。 This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.

public:
 SqlMetaData(System::String ^ name, System::Data::SqlDbType dbType, long maxLength, System::Byte precision, System::Byte scale, long localeId, System::Data::SqlTypes::SqlCompareOptions compareOptions, Type ^ userDefinedType, bool useServerDefault, bool isUniqueKey, System::Data::SqlClient::SortOrder columnSortOrder, int sortOrdinal);
public SqlMetaData (string name, System.Data.SqlDbType dbType, long maxLength, byte precision, byte scale, long localeId, System.Data.SqlTypes.SqlCompareOptions compareOptions, Type userDefinedType, bool useServerDefault, bool isUniqueKey, System.Data.SqlClient.SortOrder columnSortOrder, int sortOrdinal);
new Microsoft.SqlServer.Server.SqlMetaData : string * System.Data.SqlDbType * int64 * byte * byte * int64 * System.Data.SqlTypes.SqlCompareOptions * Type * bool * bool * System.Data.SqlClient.SortOrder * int -> Microsoft.SqlServer.Server.SqlMetaData
Public Sub New (name As String, dbType As SqlDbType, maxLength As Long, precision As Byte, scale As Byte, localeId As Long, compareOptions As SqlCompareOptions, userDefinedType As Type, useServerDefault As Boolean, isUniqueKey As Boolean, columnSortOrder As SortOrder, sortOrdinal As Integer)

参数

name
String String String String

列的名称。 The name of the column.

dbType
SqlDbType SqlDbType SqlDbType SqlDbType

参数或列的 SQL Server 类型。 The SQL Server type of the parameter or column.

maxLength
Int64 Int64 Int64 Int64

指定类型的最大长度。 The maximum length of the specified type.

precision
Byte Byte Byte Byte

参数或列的精度。 The precision of the parameter or column.

scale
Byte Byte Byte Byte

参数或列的小数位数。 The scale of the parameter or column.

localeId
Int64 Int64 Int64 Int64

参数或列的区域设置 ID。 The locale ID of the parameter or column.

compareOptions
SqlCompareOptions SqlCompareOptions SqlCompareOptions SqlCompareOptions

参数或列的比较规则。 The comparison rules of the parameter or column.

userDefinedType
Type Type Type Type

一个指向该 UDT 的 Type 实例。 A Type instance that points to the UDT.

useServerDefault
Boolean Boolean Boolean Boolean

指定此列是否应使用默认服务器值。 Specifes whether this column should use the default server value.

isUniqueKey
Boolean Boolean Boolean Boolean

指定表值参数中的列是否唯一。 Specifies if the column in the table-valued parameter is unique.

columnSortOrder
SortOrder SortOrder SortOrder SortOrder

指定列的排序顺序。 Specifies the sort order for a column.

sortOrdinal
Int32 Int32 Int32 Int32

指定列排序的序号。 Specifies the ordinal of the sort column.

Remarks

有关详细信息,请参阅表值参数For more information, see Table-Valued Parameters.

SqlMetaData(String, SqlDbType, String, String, String, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, String, String, String, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, String, String, String, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, String, String, String, Boolean, Boolean, SortOrder, Int32)

使用指定的列名称、数据库名称、所属架构、对象名称和默认服务器初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, database name, owning schema, object name, and default server. 这种形式的构造函数通过允许指定表值参数中的列是否唯一、列的排序顺序和列排序的序号,支持表值参数。 This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.

public:
 SqlMetaData(System::String ^ name, System::Data::SqlDbType dbType, System::String ^ database, System::String ^ owningSchema, System::String ^ objectName, bool useServerDefault, bool isUniqueKey, System::Data::SqlClient::SortOrder columnSortOrder, int sortOrdinal);
public SqlMetaData (string name, System.Data.SqlDbType dbType, string database, string owningSchema, string objectName, bool useServerDefault, bool isUniqueKey, System.Data.SqlClient.SortOrder columnSortOrder, int sortOrdinal);
new Microsoft.SqlServer.Server.SqlMetaData : string * System.Data.SqlDbType * string * string * string * bool * bool * System.Data.SqlClient.SortOrder * int -> Microsoft.SqlServer.Server.SqlMetaData
Public Sub New (name As String, dbType As SqlDbType, database As String, owningSchema As String, objectName As String, useServerDefault As Boolean, isUniqueKey As Boolean, columnSortOrder As SortOrder, sortOrdinal As Integer)

参数

name
String String String String

列的名称。 The name of the column.

dbType
SqlDbType SqlDbType SqlDbType SqlDbType

参数或列的 SQL Server 类型。 The SQL Server type of the parameter or column.

database
String String String String

类型化 XML 实例的 XML 架构集合的数据库名称。 The database name of the XML schema collection of a typed XML instance.

owningSchema
String String String String

类型化 XML 实例的 XML 架构集合的关系架构名称。 The relational schema name of the XML schema collection of a typed XML instance.

objectName
String String String String

类型化 XML 实例的 XML 架构集合的名称。 The name of the XML schema collection of a typed XML instance.

useServerDefault
Boolean Boolean Boolean Boolean

指定此列是否应使用默认服务器值。 Specifes whether this column should use the default server value.

isUniqueKey
Boolean Boolean Boolean Boolean

指定表值参数中的列是否唯一。 Specifies if the column in the table-valued parameter is unique.

columnSortOrder
SortOrder SortOrder SortOrder SortOrder

指定列的排序顺序。 Specifies the sort order for a column.

sortOrdinal
Int32 Int32 Int32 Int32

指定列排序的序号。 Specifies the ordinal of the sort column.

Remarks

有关详细信息,请参阅表值参数For more information, see Table-Valued Parameters.

SqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions, Boolean, Boolean, SortOrder, Int32)

使用指定的列名称、类型、最大长度、区域设置、比较选项和服务器默认值初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, type, maximum length, locale, compare options, and server default. 这种形式的构造函数通过允许指定表值参数中的列是否唯一、列的排序顺序和列排序的序号,支持表值参数。 This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.

public:
 SqlMetaData(System::String ^ name, System::Data::SqlDbType dbType, long maxLength, long locale, System::Data::SqlTypes::SqlCompareOptions compareOptions, bool useServerDefault, bool isUniqueKey, System::Data::SqlClient::SortOrder columnSortOrder, int sortOrdinal);
public SqlMetaData (string name, System.Data.SqlDbType dbType, long maxLength, long locale, System.Data.SqlTypes.SqlCompareOptions compareOptions, bool useServerDefault, bool isUniqueKey, System.Data.SqlClient.SortOrder columnSortOrder, int sortOrdinal);
new Microsoft.SqlServer.Server.SqlMetaData : string * System.Data.SqlDbType * int64 * int64 * System.Data.SqlTypes.SqlCompareOptions * bool * bool * System.Data.SqlClient.SortOrder * int -> Microsoft.SqlServer.Server.SqlMetaData
Public Sub New (name As String, dbType As SqlDbType, maxLength As Long, locale As Long, compareOptions As SqlCompareOptions, useServerDefault As Boolean, isUniqueKey As Boolean, columnSortOrder As SortOrder, sortOrdinal As Integer)

参数

name
String String String String

列的名称。 The name of the column.

dbType
SqlDbType SqlDbType SqlDbType SqlDbType

参数或列的 SQL Server 类型。 The SQL Server type of the parameter or column.

maxLength
Int64 Int64 Int64 Int64

指定类型的最大长度。 The maximum length of the specified type.

locale
Int64 Int64 Int64 Int64

参数或列的区域设置 ID。 The locale ID of the parameter or column.

compareOptions
SqlCompareOptions SqlCompareOptions SqlCompareOptions SqlCompareOptions

参数或列的比较规则。 The comparison rules of the parameter or column.

useServerDefault
Boolean Boolean Boolean Boolean

指定此列是否应使用默认服务器值。 Specifes whether this column should use the default server value.

isUniqueKey
Boolean Boolean Boolean Boolean

指定表值参数中的列是否唯一。 Specifies if the column in the table-valued parameter is unique.

columnSortOrder
SortOrder SortOrder SortOrder SortOrder

指定列的排序顺序。 Specifies the sort order for a column.

sortOrdinal
Int32 Int32 Int32 Int32

指定列排序的序号。 Specifies the ordinal of the sort column.

Remarks

有关详细信息,请参阅表值参数For more information, see Table-Valued Parameters.

SqlMetaData(String, SqlDbType, Type, String, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Type, String, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Type, String, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Type, String, Boolean, Boolean, SortOrder, Int32)

使用指定的列名称、类型、用户定义的类型、SQL Server 类型和服务器默认值初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, type, user-defined type, SQL Server type, and server default. 这种形式的构造函数通过允许指定表值参数中的列是否唯一、列的排序顺序和列排序的序号,支持表值参数。 This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.

public:
 SqlMetaData(System::String ^ name, System::Data::SqlDbType dbType, Type ^ userDefinedType, System::String ^ serverTypeName, bool useServerDefault, bool isUniqueKey, System::Data::SqlClient::SortOrder columnSortOrder, int sortOrdinal);
public SqlMetaData (string name, System.Data.SqlDbType dbType, Type userDefinedType, string serverTypeName, bool useServerDefault, bool isUniqueKey, System.Data.SqlClient.SortOrder columnSortOrder, int sortOrdinal);
new Microsoft.SqlServer.Server.SqlMetaData : string * System.Data.SqlDbType * Type * string * bool * bool * System.Data.SqlClient.SortOrder * int -> Microsoft.SqlServer.Server.SqlMetaData
Public Sub New (name As String, dbType As SqlDbType, userDefinedType As Type, serverTypeName As String, useServerDefault As Boolean, isUniqueKey As Boolean, columnSortOrder As SortOrder, sortOrdinal As Integer)

参数

name
String String String String

列的名称。 The name of the column.

dbType
SqlDbType SqlDbType SqlDbType SqlDbType

参数或列的 SQL Server 类型。 The SQL Server type of the parameter or column.

userDefinedType
Type Type Type Type

一个指向该 UDT 的 Type 实例。 A Type instance that points to the UDT.

serverTypeName
String String String String

userDefinedType 的 SQL Server 类型名称。 The SQL Server type name for userDefinedType.

useServerDefault
Boolean Boolean Boolean Boolean

指定此列是否应使用默认服务器值。 Specifes whether this column should use the default server value.

isUniqueKey
Boolean Boolean Boolean Boolean

指定表值参数中的列是否唯一。 Specifies if the column in the table-valued parameter is unique.

columnSortOrder
SortOrder SortOrder SortOrder SortOrder

指定列的排序顺序。 Specifies the sort order for a column.

sortOrdinal
Int32 Int32 Int32 Int32

指定列排序的序号。 Specifies the ordinal of the sort column.

Remarks

有关详细信息,请参阅表值参数For more information, see Table-Valued Parameters.

SqlMetaData(String, SqlDbType, Byte, Byte, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Byte, Byte, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Byte, Byte, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Byte, Byte, Boolean, Boolean, SortOrder, Int32)

使用指定的列名称、类型、精度、小数位数和服务器默认值初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, type, precision, scale, and server default. 这种形式的构造函数通过允许指定表值参数中的列是否唯一、列的排序顺序和列排序的序号,支持表值参数。 This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.

public:
 SqlMetaData(System::String ^ name, System::Data::SqlDbType dbType, System::Byte precision, System::Byte scale, bool useServerDefault, bool isUniqueKey, System::Data::SqlClient::SortOrder columnSortOrder, int sortOrdinal);
public SqlMetaData (string name, System.Data.SqlDbType dbType, byte precision, byte scale, bool useServerDefault, bool isUniqueKey, System.Data.SqlClient.SortOrder columnSortOrder, int sortOrdinal);
new Microsoft.SqlServer.Server.SqlMetaData : string * System.Data.SqlDbType * byte * byte * bool * bool * System.Data.SqlClient.SortOrder * int -> Microsoft.SqlServer.Server.SqlMetaData
Public Sub New (name As String, dbType As SqlDbType, precision As Byte, scale As Byte, useServerDefault As Boolean, isUniqueKey As Boolean, columnSortOrder As SortOrder, sortOrdinal As Integer)

参数

name
String String String String

列的名称。 The name of the column.

dbType
SqlDbType SqlDbType SqlDbType SqlDbType

参数或列的 SQL Server 类型。 The SQL Server type of the parameter or column.

precision
Byte Byte Byte Byte

参数或列的精度。 The precision of the parameter or column.

scale
Byte Byte Byte Byte

参数或列的小数位数。 The scale of the parameter or column.

useServerDefault
Boolean Boolean Boolean Boolean

指定此列是否应使用默认服务器值。 Specifes whether this column should use the default server value.

isUniqueKey
Boolean Boolean Boolean Boolean

指定表值参数中的列是否唯一。 Specifies if the column in the table-valued parameter is unique.

columnSortOrder
SortOrder SortOrder SortOrder SortOrder

指定列的排序顺序。 Specifies the sort order for a column.

sortOrdinal
Int32 Int32 Int32 Int32

指定列排序的序号。 Specifies the ordinal of the sort column.

Remarks

有关详细信息,请参阅表值参数For more information, see Table-Valued Parameters.

SqlMetaData(String, SqlDbType, Int64, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Int64, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Int64, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Int64, Boolean, Boolean, SortOrder, Int32)

使用指定的列名称、类型、最大长度和服务器默认值初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, type, maximum length, and server default. 这种形式的构造函数通过允许指定表值参数中的列是否唯一、列的排序顺序和列排序的序号,支持表值参数。 This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.

public:
 SqlMetaData(System::String ^ name, System::Data::SqlDbType dbType, long maxLength, bool useServerDefault, bool isUniqueKey, System::Data::SqlClient::SortOrder columnSortOrder, int sortOrdinal);
public SqlMetaData (string name, System.Data.SqlDbType dbType, long maxLength, bool useServerDefault, bool isUniqueKey, System.Data.SqlClient.SortOrder columnSortOrder, int sortOrdinal);
new Microsoft.SqlServer.Server.SqlMetaData : string * System.Data.SqlDbType * int64 * bool * bool * System.Data.SqlClient.SortOrder * int -> Microsoft.SqlServer.Server.SqlMetaData
Public Sub New (name As String, dbType As SqlDbType, maxLength As Long, useServerDefault As Boolean, isUniqueKey As Boolean, columnSortOrder As SortOrder, sortOrdinal As Integer)

参数

name
String String String String

列的名称。 The name of the column.

dbType
SqlDbType SqlDbType SqlDbType SqlDbType

参数或列的 SQL Server 类型。 The SQL Server type of the parameter or column.

maxLength
Int64 Int64 Int64 Int64

指定类型的最大长度。 The maximum length of the specified type.

useServerDefault
Boolean Boolean Boolean Boolean

指定此列是否应使用默认服务器值。 Specifes whether this column should use the default server value.

isUniqueKey
Boolean Boolean Boolean Boolean

指定表值参数中的列是否唯一。 Specifies if the column in the table-valued parameter is unique.

columnSortOrder
SortOrder SortOrder SortOrder SortOrder

指定列的排序顺序。 Specifies the sort order for a column.

sortOrdinal
Int32 Int32 Int32 Int32

指定列排序的序号。 Specifies the ordinal of the sort column.

Remarks

有关详细信息,请参阅表值参数For more information, see Table-Valued Parameters.

SqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type) SqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type) SqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type) SqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type)

使用指定的列名称、类型、最大长度、精度、小数位数、区域设置 ID、比较选项和用户定义的类型 (UDT) 初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, type, maximum length, precision, scale, locale ID, compare options, and user-defined type (UDT).

public:
 SqlMetaData(System::String ^ name, System::Data::SqlDbType dbType, long maxLength, System::Byte precision, System::Byte scale, long locale, System::Data::SqlTypes::SqlCompareOptions compareOptions, Type ^ userDefinedType);
public SqlMetaData (string name, System.Data.SqlDbType dbType, long maxLength, byte precision, byte scale, long locale, System.Data.SqlTypes.SqlCompareOptions compareOptions, Type userDefinedType);
new Microsoft.SqlServer.Server.SqlMetaData : string * System.Data.SqlDbType * int64 * byte * byte * int64 * System.Data.SqlTypes.SqlCompareOptions * Type -> Microsoft.SqlServer.Server.SqlMetaData
Public Sub New (name As String, dbType As SqlDbType, maxLength As Long, precision As Byte, scale As Byte, locale As Long, compareOptions As SqlCompareOptions, userDefinedType As Type)

参数

name
String String String String

列的名称。 The name of the column.

dbType
SqlDbType SqlDbType SqlDbType SqlDbType

参数或列的 SQL Server 类型。 The SQL Server type of the parameter or column.

maxLength
Int64 Int64 Int64 Int64

指定类型的最大长度。 The maximum length of the specified type.

precision
Byte Byte Byte Byte

参数或列的精度。 The precision of the parameter or column.

scale
Byte Byte Byte Byte

参数或列的小数位数。 The scale of the parameter or column.

locale
Int64 Int64 Int64 Int64

参数或列的区域设置 ID。 The locale ID of the parameter or column.

compareOptions
SqlCompareOptions SqlCompareOptions SqlCompareOptions SqlCompareOptions

参数或列的比较规则。 The comparison rules of the parameter or column.

userDefinedType
Type Type Type Type

一个指向该 UDT 的 Type 实例。 A Type instance that points to the UDT.

Exceptions

不允许的 SqlDbType 作为 dbType 传递给了构造函数,或者 userDefinedType 指向了未声明 SqlUserDefinedTypeAttribute 的类型。 A SqlDbType that is not allowed was passed to the constructor as dbType, or userDefinedType points to a type that does not have SqlUserDefinedTypeAttribute declared.

Remarks

仅以下允许传递给构造函数、 作为dbType: BigIntBitBitIntDateTimeDecimalFloatImageIntMoneyNtext, Numeric, Real, SmallDateTime, SmallInt, SmallMoney, Text, TimeStamp, TinyInt, UniqueIdentifier, Variant, Xml.Only the following are allowed to be passed to the constructor as dbType: BigInt, Bit, BitInt, DateTime, Decimal, Float, Image, Int, Money, Ntext, Numeric, Real, SmallDateTime, SmallInt, SmallMoney, Text, TimeStamp, TinyInt, UniqueIdentifier, Variant, Xml.

以下是分配给默认值dbType,具体取决于SqlDbType( XmlSchemaCollectionDatabaseXmlSchemaCollectionNameXmlSchemaCollectionOwningSchema,并且Type属性设置为null):The following are the default values assigned to dbType, depending on the SqlDbType (the XmlSchemaCollectionDatabase, XmlSchemaCollectionName, XmlSchemaCollectionOwningSchema, and Type properties are set to null):

SqlDbTypeSqlDbType 最大长度Maximum length 精度Precision 缩放Scale 区域设置Locale 比较选项Compare options
BigInt 88 1919 00 00 None
Bit 11 11 00 00 None
DateTime 88 2323 33 00 None
Decimal 99 1818 00 00 None
Float 88 5353 00 00 None
Image 最大值 (-1)Max (-1) 00 00 00 None
Int 44 1010 00 00 None
Money 88 1919 44 00 None
Ntext 最大值 (-1)Max (-1) 00 00 <线程 ><thread> IgnoreCase, IgnoreKanaType, IgnoreWidthIgnoreCase, IgnoreKanaType, IgnoreWidth
Real 44 2424 00 00 None
Row <列数 ><number of columns> 00 00 00 None
SmallDateTime 44 1616 00 00 None
SmallInt 22 55 00 00 None
SmallMoney 44 1010 44 00 None
Text 最大值 (-1)Max (-1) 00 00 <线程 ><thread> IgnoreCase, IgnoreKanaType, IgnoreWidthIgnoreCase, IgnoreKanaType, IgnoreWidth
TimeStamp 88 00 00 00 None
TinyInt 11 33 00 00 None
UniqueIdentifier 1616 00 00 00 None
UDT <类型的最大长度 > 或-1<Max length of the type> or -1 00 00 00 None
Variant 80168016 00 00 00 None
Xml 最大值 (-1)Max (-1) 00 00 00 IgnoreCase, IgnoreKanaType, IgnoreWidthIgnoreCase, IgnoreKanaType, IgnoreWidth

SqlMetaData(String, SqlDbType, String, String, String) SqlMetaData(String, SqlDbType, String, String, String) SqlMetaData(String, SqlDbType, String, String, String) SqlMetaData(String, SqlDbType, String, String, String)

使用指定的列名称、类型、数据库名称、所属架构和对象名称初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, type, database name, owning schema, and object name.

public:
 SqlMetaData(System::String ^ name, System::Data::SqlDbType dbType, System::String ^ database, System::String ^ owningSchema, System::String ^ objectName);
public SqlMetaData (string name, System.Data.SqlDbType dbType, string database, string owningSchema, string objectName);
new Microsoft.SqlServer.Server.SqlMetaData : string * System.Data.SqlDbType * string * string * string -> Microsoft.SqlServer.Server.SqlMetaData
Public Sub New (name As String, dbType As SqlDbType, database As String, owningSchema As String, objectName As String)

参数

name
String String String String

列的名称。 The name of the column.

dbType
SqlDbType SqlDbType SqlDbType SqlDbType

参数或列的 SQL Server 类型。 The SQL Server type of the parameter or column.

database
String String String String

类型化 XML 实例的 XML 架构集合的数据库名称。 The database name of the XML schema collection of a typed XML instance.

owningSchema
String String String String

类型化 XML 实例的 XML 架构集合的关系架构名称。 The relational schema name of the XML schema collection of a typed XML instance.

objectName
String String String String

类型化 XML 实例的 XML 架构集合的名称。 The name of the XML schema collection of a typed XML instance.

Exceptions

NameobjectName 不为 null 时,databasenull,或 owningSchemanull The Name is null, or objectName is null when database and owningSchema are non-null.

不允许的 SqlDbType 作为 dbType 传递给了构造函数。 A SqlDbType that is not allowed was passed to the constructor as dbType.

Remarks

仅以下SqlDbType允许传递给构造函数、 作为dbType: XmlOnly the following SqlDbType is allowed to be passed to the constructor as dbType: Xml.

以下是分配给默认值dbType,具体取决于SqlDbType:The following are the default values assigned to dbType, depending on the SqlDbType:

SqlDbTypeSqlDbType 最大长度Maximum length 精度Precision 缩放Scale 区域设置Locale 比较选项Compare options
Xml 最大值 (-1)Max (-1) 00 00 00 IgnoreCase, IgnoreKanaType, IgnoreWidthIgnoreCase, IgnoreKanaType, IgnoreWidth

SqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions) SqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions) SqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions) SqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions)

使用指定的列名称、类型、最大长度、区域设置和比较选项初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, type, maximum length, locale, and compare options.

public:
 SqlMetaData(System::String ^ name, System::Data::SqlDbType dbType, long maxLength, long locale, System::Data::SqlTypes::SqlCompareOptions compareOptions);
public SqlMetaData (string name, System.Data.SqlDbType dbType, long maxLength, long locale, System.Data.SqlTypes.SqlCompareOptions compareOptions);
new Microsoft.SqlServer.Server.SqlMetaData : string * System.Data.SqlDbType * int64 * int64 * System.Data.SqlTypes.SqlCompareOptions -> Microsoft.SqlServer.Server.SqlMetaData
Public Sub New (name As String, dbType As SqlDbType, maxLength As Long, locale As Long, compareOptions As SqlCompareOptions)

参数

name
String String String String

参数或列的名称。 The name of the parameter or column.

dbType
SqlDbType SqlDbType SqlDbType SqlDbType

参数或列的 SQL Server 类型。 The SQL Server type of the parameter or column.

maxLength
Int64 Int64 Int64 Int64

指定类型的最大长度。 The maximum length of the specified type.

locale
Int64 Int64 Int64 Int64

参数或列的区域设置 ID。 The locale ID of the parameter or column.

compareOptions
SqlCompareOptions SqlCompareOptions SqlCompareOptions SqlCompareOptions

参数或列的比较规则。 The comparison rules of the parameter or column.

Exceptions

不允许的 SqlDbType 作为 dbType 传递给了构造函数。 A SqlDbType that is not allowed was passed to the constructor as dbType.

Remarks

仅以下允许传递给构造函数、 作为dbType: CharNCharNtextNVarCharTextVarCharOnly the following are allowed to be passed to the constructor as dbType: Char, NChar, Ntext, NVarChar, Text, VarChar.

maxLength的规范Max,或为-1,允许用于dbTypeTextNTextOnly a maxLength specification of Max, or -1, is allowed for a dbType of Text or NText.

有关dbTypeVarcharNvarchar,长度规定的Max,-1,会将元数据分别声明为 varchar (max) 和 nvarchar (max)、 或。For a dbType of Varchar or Nvarchar, a length specification of Max, or -1, declares the metadata as varchar(max) and nvarchar(max), respectively.

以下是分配给默认值dbType,具体取决于SqlDbType( XmlSchemaCollectionDatabaseXmlSchemaCollectionNameXmlSchemaCollectionOwningSchema,并且Type属性设置为null):The following are the default values assigned to dbType, depending on the SqlDbType (the XmlSchemaCollectionDatabase, XmlSchemaCollectionName, XmlSchemaCollectionOwningSchema, and Type properties are set to null):

SqlDbTypeSqlDbType 精度Precision 缩放Scale
Char 00 00
NChar 00 00
NText 00 00
NVarChar 00 00
Text 00 00
VarChar 00 00

SqlMetaData(String, SqlDbType, Type, String) SqlMetaData(String, SqlDbType, Type, String) SqlMetaData(String, SqlDbType, Type, String) SqlMetaData(String, SqlDbType, Type, String)

使用指定的列名称、用户定义的类型 (UDT) 和 SQLServer 类型初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, user-defined type (UDT), and SQLServer type.

public:
 SqlMetaData(System::String ^ name, System::Data::SqlDbType dbType, Type ^ userDefinedType, System::String ^ serverTypeName);
public SqlMetaData (string name, System.Data.SqlDbType dbType, Type userDefinedType, string serverTypeName);
new Microsoft.SqlServer.Server.SqlMetaData : string * System.Data.SqlDbType * Type * string -> Microsoft.SqlServer.Server.SqlMetaData
Public Sub New (name As String, dbType As SqlDbType, userDefinedType As Type, serverTypeName As String)

参数

name
String String String String

列的名称。 The name of the column.

dbType
SqlDbType SqlDbType SqlDbType SqlDbType

参数或列的 SQL Server 类型。 The SQL Server type of the parameter or column.

userDefinedType
Type Type Type Type

一个指向该 UDT 的 Type 实例。 A Type instance that points to the UDT.

serverTypeName
String String String String

userDefinedType 的 SQL Server 类型名称。 The SQL Server type name for userDefinedType.

SqlMetaData(String, SqlDbType, Byte, Byte) SqlMetaData(String, SqlDbType, Byte, Byte) SqlMetaData(String, SqlDbType, Byte, Byte) SqlMetaData(String, SqlDbType, Byte, Byte)

使用指定的列名称、类型、精度和小数位数初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, type, precision, and scale.

public:
 SqlMetaData(System::String ^ name, System::Data::SqlDbType dbType, System::Byte precision, System::Byte scale);
public SqlMetaData (string name, System.Data.SqlDbType dbType, byte precision, byte scale);
new Microsoft.SqlServer.Server.SqlMetaData : string * System.Data.SqlDbType * byte * byte -> Microsoft.SqlServer.Server.SqlMetaData
Public Sub New (name As String, dbType As SqlDbType, precision As Byte, scale As Byte)

参数

name
String String String String

参数或列的名称。 The name of the parameter or column.

dbType
SqlDbType SqlDbType SqlDbType SqlDbType

参数或列的 SQL Server 类型。 The SQL Server type of the parameter or column.

precision
Byte Byte Byte Byte

参数或列的精度。 The precision of the parameter or column.

scale
Byte Byte Byte Byte

参数或列的小数位数。 The scale of the parameter or column.

Exceptions

不允许的 SqlDbType 作为 dbType 传递给了构造函数,或者 scale 大于 precision A SqlDbType that is not allowed was passed to the constructor as dbType, or scale was greater than precision.

Remarks

仅以下SqlDbType允许传递给构造函数、 作为dbType: DecimalOnly the following SqlDbType is allowed to be passed to the constructor as dbType: Decimal.

以下是分配给默认值dbType,具体取决于SqlDbType( XmlSchemaCollectionDatabaseXmlSchemaCollectionNameXmlSchemaCollectionOwningSchema,并且Type属性设置为null):The following are the default values assigned to dbType, depending on the SqlDbType (the XmlSchemaCollectionDatabase, XmlSchemaCollectionName, XmlSchemaCollectionOwningSchema, and Type properties are set to null):

SqlDbTypeSqlDbType 最大长度Maximum length 精度Precision 缩放Scale 区域设置Locale 比较选项Compare options
十进制Decimal 99 1818 00 00 None

SqlMetaData(String, SqlDbType, Type) SqlMetaData(String, SqlDbType, Type) SqlMetaData(String, SqlDbType, Type) SqlMetaData(String, SqlDbType, Type)

使用指定的列名称、类型和用户定义的类型 (UDT) 初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, type, and user-defined type (UDT).

public:
 SqlMetaData(System::String ^ name, System::Data::SqlDbType dbType, Type ^ userDefinedType);
public SqlMetaData (string name, System.Data.SqlDbType dbType, Type userDefinedType);
new Microsoft.SqlServer.Server.SqlMetaData : string * System.Data.SqlDbType * Type -> Microsoft.SqlServer.Server.SqlMetaData
Public Sub New (name As String, dbType As SqlDbType, userDefinedType As Type)

参数

name
String String String String

列的名称。 The name of the column.

dbType
SqlDbType SqlDbType SqlDbType SqlDbType

参数或列的 SQL Server 类型。 The SQL Server type of the parameter or column.

userDefinedType
Type Type Type Type

一个指向该 UDT 的 Type 实例。 A Type instance that points to the UDT.

Exceptions

不允许的 SqlDbType 作为 dbType 传递给了构造函数,或者 userDefinedType 指向了未声明 SqlUserDefinedTypeAttribute 的类型。 A SqlDbType that is not allowed was passed to the constructor as dbType, or userDefinedType points to a type that does not have SqlUserDefinedTypeAttribute declared.

Remarks

仅以下SqlDbType允许传递给构造函数、 作为dbType: UDTOnly the following SqlDbType is allowed to be passed to the constructor as dbType: UDT.

以下是分配给默认值dbType,具体取决于SqlDbType( XmlSchemaCollectionDatabaseXmlSchemaCollectionNameXmlSchemaCollectionOwningSchema,并且Type属性设置为null):The following are the default values assigned to dbType, depending on the SqlDbType (the XmlSchemaCollectionDatabase, XmlSchemaCollectionName, XmlSchemaCollectionOwningSchema, and Type properties are set to null):

SqlDbTypeSqlDbType 最大长度Maximum length 精度Precision 缩放Scale 区域设置Locale 比较选项Compare options
UDTUDT <类型的最大长度 > 或-1<Max length of the type> or -1 00 00 00 None

SqlMetaData(String, SqlDbType, Int64) SqlMetaData(String, SqlDbType, Int64) SqlMetaData(String, SqlDbType, Int64) SqlMetaData(String, SqlDbType, Int64)

使用指定的列名称、类型和最大长度初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, type, and maximum length.

public:
 SqlMetaData(System::String ^ name, System::Data::SqlDbType dbType, long maxLength);
public SqlMetaData (string name, System.Data.SqlDbType dbType, long maxLength);
new Microsoft.SqlServer.Server.SqlMetaData : string * System.Data.SqlDbType * int64 -> Microsoft.SqlServer.Server.SqlMetaData
Public Sub New (name As String, dbType As SqlDbType, maxLength As Long)

参数

name
String String String String

列的名称。 The name of the column.

dbType
SqlDbType SqlDbType SqlDbType SqlDbType

参数或列的 SQL Server 类型。 The SQL Server type of the parameter or column.

maxLength
Int64 Int64 Int64 Int64

指定类型的最大长度。 The maximum length of the specified type.

Exceptions

不允许的 SqlDbType 作为 dbType 传递给了构造函数。 A SqlDbType that is not allowed was passed to the constructor as dbType.

Examples

下面的示例创建一个新SqlMetaData通过指定列名称的列数据类型的对象SqlDbType .NVarChar,并且最大长度为 12 个字符。The following example creates a new SqlMetaData object by specifying the column name, a column data type of SqlDbType.NVarChar, and a maximum length of 12 characters.

public static void CreateSqlMetaData1()
{
   SqlMetaData columnInfo;
   columnInfo = new SqlMetaData("Column1", SqlDbType.NVarChar, 12);
}
Public Shared Sub CreateSqlMetaData1()

   Dim columnInfo As SqlMetaData
   columnInfo = new SqlMetaData("ColumnName", SqlDbType.NVarChar, 12)

End Sub

Remarks

仅以下允许传递给构造函数、 作为dbType: BinaryCharImageNCharNtextNVarCharTextVarBinaryVarCharOnly the following are allowed to be passed to the constructor as dbType: Binary, Char, Image, NChar, Ntext, NVarChar, Text, VarBinary, VarChar.

maxLength的规范Max,或为-1 允许用于dbTypeTextNText,或ImageOnly a maxLength specification of Max, or -1 is allowed for a dbType of Text, NText, or Image.

有关dbTypeVarcharNvarchar,或VarBinary,长度规定的Max,或为-1,会将元数据分别声明为 varchar (max)、 nvarchar (max) 或 nvarbinary(max)。For a dbType of Varchar, Nvarchar, or VarBinary, a length specification of Max, or -1, declares the metadata as varchar(max), nvarchar(max), or nvarbinary(max), respectively.

以下是分配给默认值dbType,具体取决于SqlDbType( XmlSchemaCollectionDatabaseXmlSchemaCollectionNameXmlSchemaCollectionOwningSchema,并且Type属性设置为null):The following are the default values assigned to dbType, depending on the SqlDbType (the XmlSchemaCollectionDatabase, XmlSchemaCollectionName, XmlSchemaCollectionOwningSchema, and Type properties are set to null):

SqlDbTypeSqlDbType 精度Precision 缩放Scale 区域设置Locale 比较选项Compare options
二进制Binary 00 00 00 IgnoreCase, IgnoreKanaType, IgnoreWidthIgnoreCase, IgnoreKanaType, IgnoreWidth
CharChar 00 00 <线程 ><thread> IgnoreCase, IgnoreKanaType, IgnoreWidthIgnoreCase, IgnoreKanaType, IgnoreWidth
图像Image 00 00 00 None
NCharNChar 00 00 <线程 ><thread> IgnoreCase, IgnoreKanaType, IgnoreWidthIgnoreCase, IgnoreKanaType, IgnoreWidth
NTextNText 00 00 <线程 ><thread> IgnoreCase, IgnoreKanaType, IgnoreWidthIgnoreCase, IgnoreKanaType, IgnoreWidth
NVarCharNVarChar 00 00 <线程 ><thread> IgnoreCase, IgnoreKanaType, IgnoreWidthIgnoreCase, IgnoreKanaType, IgnoreWidth
TextText 00 00 <线程 ><thread> IgnoreCase, IgnoreKanaType, IgnoreWidthIgnoreCase, IgnoreKanaType, IgnoreWidth
VarBinaryVarBinary 00 00 IgnoreCase, IgnoreKanaType, IgnoreWidthIgnoreCase, IgnoreKanaType, IgnoreWidth
VarCharVarChar 00 00 <线程 ><thread> IgnoreCase, IgnoreKanaType, IgnoreWidthIgnoreCase, IgnoreKanaType, IgnoreWidth

SqlMetaData(String, SqlDbType, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Boolean, Boolean, SortOrder, Int32) SqlMetaData(String, SqlDbType, Boolean, Boolean, SortOrder, Int32)

使用指定的列名称和默认服务器初始化 SqlMetaData 类的新实例。 Initializes a new instance of the SqlMetaData class with the specified column name, and default server. 这种形式的构造函数通过允许指定表值参数中的列是否唯一、列的排序顺序和列排序的序号,支持表值参数。 This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column.

public:
 SqlMetaData(System::String ^ name, System::Data::SqlDbType dbType, bool useServerDefault, bool isUniqueKey, System::Data::SqlClient::SortOrder columnSortOrder, int sortOrdinal);
public SqlMetaData (string name, System.Data.SqlDbType dbType, bool useServerDefault, bool isUniqueKey, System.Data.SqlClient.SortOrder columnSortOrder, int sortOrdinal);
new Microsoft.SqlServer.Server.SqlMetaData : string * System.Data.SqlDbType * bool * bool * System.Data.SqlClient.SortOrder * int -> Microsoft.SqlServer.Server.SqlMetaData
Public Sub New (name As String, dbType As SqlDbType, useServerDefault As Boolean, isUniqueKey As Boolean, columnSortOrder As SortOrder, sortOrdinal As Integer)

参数

name
String String String String

列的名称。 The name of the column.

dbType
SqlDbType SqlDbType SqlDbType SqlDbType

参数或列的 SQL Server 类型。 The SQL Server type of the parameter or column.

useServerDefault
Boolean Boolean Boolean Boolean

指定此列是否应使用默认服务器值。 Specifes whether this column should use the default server value.

isUniqueKey
Boolean Boolean Boolean Boolean

指定表值参数中的列是否唯一。 Specifies if the column in the table-valued parameter is unique.

columnSortOrder
SortOrder SortOrder SortOrder SortOrder

指定列的排序顺序。 Specifies the sort order for a column.

sortOrdinal
Int32 Int32 Int32 Int32

指定列排序的序号。 Specifies the ordinal of the sort column.

Remarks

有关详细信息,请参阅表值参数For more information, see Table-Valued Parameters.

Applies to