语言

SqlMetaData 构造函数

定义

重载

名称 说明
SqlMetaData(String, SqlDbType)

使用指定的列名称和类型初始化类的新实例 SqlMetaData 。

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

使用指定的列名、类型、最大长度、精度、刻度、区域设置 ID、比较选项和用户定义的类型(UDT)初始化类的新实例 SqlMetaData 。 这种形式的构造函数支持表值参数,即允许指定列在表值参数中是否唯一、该列的排序顺序以及排序列的序号。

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

使用指定的列名、数据库名称、拥有架构、对象名称和默认服务器初始化类的新实例 SqlMetaData 。 这种形式的构造函数支持表值参数,即允许指定列在表值参数中是否唯一、该列的排序顺序以及排序列的序号。

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

使用指定的列名称、类型、最大长度、区域设置、比较选项和服务器默认值初始化类的新实例 SqlMetaData 。 这种形式的构造函数支持表值参数,即允许指定列在表值参数中是否唯一、该列的排序顺序以及排序列的序号。

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

使用指定的列名、类型、用户定义类型、SQL Server类型和服务器默认值初始化类的新实例SqlMetaData。 这种形式的构造函数支持表值参数,即允许指定列在表值参数中是否唯一、该列的排序顺序以及排序列的序号。

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

使用指定的列名、类型、精度、小数位数和服务器默认值初始化类的新实例 SqlMetaData 。 这种形式的构造函数支持表值参数,即允许指定列在表值参数中是否唯一、该列的排序顺序以及排序列的序号。

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

使用指定的列名称、类型、最大长度和服务器默认值初始化类的新实例 SqlMetaData 。 这种形式的构造函数支持表值参数,即允许指定列在表值参数中是否唯一、该列的排序顺序以及排序列的序号。

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

使用指定的列名、类型、最大长度、精度、刻度、区域设置 ID、比较选项和用户定义的类型(UDT)初始化类的新实例 SqlMetaData 。

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

使用指定的列名称、类型、数据库名称、拥有架构和对象名称初始化类的新实例 SqlMetaData 。

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

使用指定的列名称、类型、最大长度、区域设置和比较选项初始化类的新实例 SqlMetaData 。

SqlMetaData(String, SqlDbType, Type, String)

使用指定的列名、用户定义的类型(UDT)和SQL Server类型初始化类的新实例SqlMetaData。

SqlMetaData(String, SqlDbType, Byte, Byte)

使用指定的列名、类型、精度和小数位数初始化类的新实例 SqlMetaData 。

SqlMetaData(String, SqlDbType, Type)

使用指定的列名、类型和用户定义的类型(UDT)初始化类的新实例 SqlMetaData 。

SqlMetaData(String, SqlDbType, Int64)

使用指定的列名、类型和最大长度初始化类的新实例 SqlMetaData 。

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

使用指定的列名和默认服务器初始化类的新实例 SqlMetaData 。 这种形式的构造函数支持表值参数,即允许指定列在表值参数中是否唯一、该列的排序顺序以及排序列的序号。

SqlMetaData(String, SqlDbType)

Source:
SqlMetaData.cs
Source:
SqlMetaData.cs
Source:
SqlMetaData.cs

使用指定的列名称和类型初始化类的新实例 SqlMetaData 。

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

参数

name
String

列的名称。

dbType
SqlDbType

参数或列的SQL Server类型。

例外

name 是 null。

不允许的项 SqlDbType 作为传递给构造函数 dbType。

示例

以下示例通过指定列名和列数据类型创建一个新 SqlMetaData 对象 Int

using Microsoft.Data.SqlClient.Server;

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

注解

仅允许将以下项传递给此构造函数:dbTypeBit、DecimalDateTimeBigInt、FloatNumericMoneyInt、、、 。 XmlUniqueIdentifierSmallDateTimeSmallIntSmallMoneyTimestampTinyInt

以下是分配给的默认值,具体取决于 > 和属性设置为 :

SqlDbType最大长度精准率比例尺/规模Locale比较选项
Bit 1100没有
BigInt 81900没有
DateTime 82330没有
Decimal 91800没有
Float 85300没有
Int 41000没有
Money 81940没有
Numeric 91800没有
SmallDateTime 41600没有
SmallInt 2500没有
SmallMoney 41040没有
Timestamp 8000没有
TinyInt 1300没有
UniqueIdentifier 16000没有
Xml Max (-1)000IgnoreCase、IgnoreKanaType、IgnoreWidth

适用于

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

Source:
SqlMetaData.cs
Source:
SqlMetaData.cs
Source:
SqlMetaData.cs

使用指定的列名、类型、最大长度、精度、刻度、区域设置 ID、比较选项和用户定义的类型(UDT)初始化类的新实例 SqlMetaData 。 这种形式的构造函数支持表值参数,即允许指定列在表值参数中是否唯一、该列的排序顺序以及排序列的序号。

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, Microsoft::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, Microsoft.Data.SqlClient.SortOrder columnSortOrder, int sortOrdinal);
new Microsoft.Data.SqlClient.Server.SqlMetaData : string * System.Data.SqlDbType * int64 * byte * byte * int64 * System.Data.SqlTypes.SqlCompareOptions * Type * bool * bool * Microsoft.Data.SqlClient.SortOrder * int -> Microsoft.Data.SqlClient.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

列的名称。

dbType
SqlDbType

参数或列的SQL Server类型。

maxLength
Int64

指定类型的最大长度。

precision
Byte

参数或列的精度。

scale
Byte

参数或列的刻度。

localeId
Int64

参数或列的区域设置 ID。

compareOptions
SqlCompareOptions

参数或列的比较规则。

userDefinedType
Type

指向 Type UDT 的实例。

useServerDefault
Boolean

指定此列是否应使用默认服务器值。

isUniqueKey
Boolean

指定表值参数中的列是否唯一。

columnSortOrder
SortOrder

指定列的排序顺序。

sortOrdinal
Int32

指定排序列的序号。

注解

有关详细信息,请参阅 Table-Valued 参数。

适用于

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

Source:
SqlMetaData.cs
Source:
SqlMetaData.cs
Source:
SqlMetaData.cs

使用指定的列名、数据库名称、拥有架构、对象名称和默认服务器初始化类的新实例 SqlMetaData 。 这种形式的构造函数支持表值参数,即允许指定列在表值参数中是否唯一、该列的排序顺序以及排序列的序号。

public:
 SqlMetaData(System::String ^ name, System::Data::SqlDbType dbType, System::String ^ database, System::String ^ owningSchema, System::String ^ objectName, bool useServerDefault, bool isUniqueKey, Microsoft::Data::SqlClient::SortOrder columnSortOrder, int sortOrdinal);
public SqlMetaData(string name, System.Data.SqlDbType dbType, string database, string owningSchema, string objectName, bool useServerDefault, bool isUniqueKey, Microsoft.Data.SqlClient.SortOrder columnSortOrder, int sortOrdinal);
new Microsoft.Data.SqlClient.Server.SqlMetaData : string * System.Data.SqlDbType * string * string * string * bool * bool * Microsoft.Data.SqlClient.SortOrder * int -> Microsoft.Data.SqlClient.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

列的名称。

dbType
SqlDbType

参数或列的SQL Server类型。

database
String

类型化的 XML 实例的 XML 架构集合的数据库名称。

owningSchema
String

类型化的 XML 实例的 XML 架构集合的关系架构名称。

objectName
String

类型化的 XML 实例的 XML 架构集合的名称。

useServerDefault
Boolean

指定此列是否应使用默认服务器值。

isUniqueKey
Boolean

指定表值参数中的列是否唯一。

columnSortOrder
SortOrder

指定列的排序顺序。

sortOrdinal
Int32

指定排序列的序号。

注解

有关详细信息,请参阅 Table-Valued 参数。

适用于

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

Source:
SqlMetaData.cs
Source:
SqlMetaData.cs
Source:
SqlMetaData.cs

使用指定的列名称、类型、最大长度、区域设置、比较选项和服务器默认值初始化类的新实例 SqlMetaData 。 这种形式的构造函数支持表值参数,即允许指定列在表值参数中是否唯一、该列的排序顺序以及排序列的序号。

public:
 SqlMetaData(System::String ^ name, System::Data::SqlDbType dbType, long maxLength, long locale, System::Data::SqlTypes::SqlCompareOptions compareOptions, bool useServerDefault, bool isUniqueKey, Microsoft::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, Microsoft.Data.SqlClient.SortOrder columnSortOrder, int sortOrdinal);
new Microsoft.Data.SqlClient.Server.SqlMetaData : string * System.Data.SqlDbType * int64 * int64 * System.Data.SqlTypes.SqlCompareOptions * bool * bool * Microsoft.Data.SqlClient.SortOrder * int -> Microsoft.Data.SqlClient.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

列的名称。

dbType
SqlDbType

参数或列的SQL Server类型。

maxLength
Int64

指定类型的最大长度。

locale
Int64

参数或列的区域设置 ID。

compareOptions
SqlCompareOptions

参数或列的比较规则。

useServerDefault
Boolean

指定此列是否应使用默认服务器值。

isUniqueKey
Boolean

指定表值参数中的列是否唯一。

columnSortOrder
SortOrder

指定列的排序顺序。

sortOrdinal
Int32

指定排序列的序号。

注解

有关详细信息,请参阅 Table-Valued 参数。

适用于

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

Source:
SqlMetaData.cs
Source:
SqlMetaData.cs
Source:
SqlMetaData.cs

使用指定的列名、类型、用户定义类型、SQL Server类型和服务器默认值初始化类的新实例SqlMetaData。 这种形式的构造函数支持表值参数,即允许指定列在表值参数中是否唯一、该列的排序顺序以及排序列的序号。

public:
 SqlMetaData(System::String ^ name, System::Data::SqlDbType dbType, Type ^ userDefinedType, System::String ^ serverTypeName, bool useServerDefault, bool isUniqueKey, Microsoft::Data::SqlClient::SortOrder columnSortOrder, int sortOrdinal);
public SqlMetaData(string name, System.Data.SqlDbType dbType, Type userDefinedType, string serverTypeName, bool useServerDefault, bool isUniqueKey, Microsoft.Data.SqlClient.SortOrder columnSortOrder, int sortOrdinal);
new Microsoft.Data.SqlClient.Server.SqlMetaData : string * System.Data.SqlDbType * Type * string * bool * bool * Microsoft.Data.SqlClient.SortOrder * int -> Microsoft.Data.SqlClient.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

列的名称。

dbType
SqlDbType

参数或列的SQL Server类型。

userDefinedType
Type

指向 Type UDT 的实例。

serverTypeName
String

SQL Server类型userDefinedType名称。

useServerDefault
Boolean

指定此列是否应使用默认服务器值。

isUniqueKey
Boolean

指定表值参数中的列是否唯一。

columnSortOrder
SortOrder

指定列的排序顺序。

sortOrdinal
Int32

指定排序列的序号。

注解

有关详细信息,请参阅 Table-Valued 参数。

适用于

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

Source:
SqlMetaData.cs
Source:
SqlMetaData.cs
Source:
SqlMetaData.cs

使用指定的列名、类型、精度、小数位数和服务器默认值初始化类的新实例 SqlMetaData 。 这种形式的构造函数支持表值参数,即允许指定列在表值参数中是否唯一、该列的排序顺序以及排序列的序号。

public:
 SqlMetaData(System::String ^ name, System::Data::SqlDbType dbType, System::Byte precision, System::Byte scale, bool useServerDefault, bool isUniqueKey, Microsoft::Data::SqlClient::SortOrder columnSortOrder, int sortOrdinal);
public SqlMetaData(string name, System.Data.SqlDbType dbType, byte precision, byte scale, bool useServerDefault, bool isUniqueKey, Microsoft.Data.SqlClient.SortOrder columnSortOrder, int sortOrdinal);
new Microsoft.Data.SqlClient.Server.SqlMetaData : string * System.Data.SqlDbType * byte * byte * bool * bool * Microsoft.Data.SqlClient.SortOrder * int -> Microsoft.Data.SqlClient.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

列的名称。

dbType
SqlDbType

参数或列的SQL Server类型。

precision
Byte

参数或列的精度。

scale
Byte

参数或列的刻度。

useServerDefault
Boolean

指定此列是否应使用默认服务器值。

isUniqueKey
Boolean

指定表值参数中的列是否唯一。

columnSortOrder
SortOrder

指定列的排序顺序。

sortOrdinal
Int32

指定排序列的序号。

注解

有关详细信息,请参阅 Table-Valued 参数。

适用于

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

Source:
SqlMetaData.cs
Source:
SqlMetaData.cs
Source:
SqlMetaData.cs

使用指定的列名称、类型、最大长度和服务器默认值初始化类的新实例 SqlMetaData 。 这种形式的构造函数支持表值参数,即允许指定列在表值参数中是否唯一、该列的排序顺序以及排序列的序号。

public:
 SqlMetaData(System::String ^ name, System::Data::SqlDbType dbType, long maxLength, bool useServerDefault, bool isUniqueKey, Microsoft::Data::SqlClient::SortOrder columnSortOrder, int sortOrdinal);
public SqlMetaData(string name, System.Data.SqlDbType dbType, long maxLength, bool useServerDefault, bool isUniqueKey, Microsoft.Data.SqlClient.SortOrder columnSortOrder, int sortOrdinal);
new Microsoft.Data.SqlClient.Server.SqlMetaData : string * System.Data.SqlDbType * int64 * bool * bool * Microsoft.Data.SqlClient.SortOrder * int -> Microsoft.Data.SqlClient.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

列的名称。

dbType
SqlDbType

参数或列的SQL Server类型。

maxLength
Int64

指定类型的最大长度。

useServerDefault
Boolean

指定此列是否应使用默认服务器值。

isUniqueKey
Boolean

指定表值参数中的列是否唯一。

columnSortOrder
SortOrder

指定列的排序顺序。

sortOrdinal
Int32

指定排序列的序号。

注解

有关详细信息,请参阅 Table-Valued 参数。

适用于

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

Source:
SqlMetaData.cs
Source:
SqlMetaData.cs
Source:
SqlMetaData.cs

使用指定的列名、类型、最大长度、精度、刻度、区域设置 ID、比较选项和用户定义的类型(UDT)初始化类的新实例 SqlMetaData 。

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.Data.SqlClient.Server.SqlMetaData : string * System.Data.SqlDbType * int64 * byte * byte * int64 * System.Data.SqlTypes.SqlCompareOptions * Type -> Microsoft.Data.SqlClient.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

列的名称。

dbType
SqlDbType

参数或列的SQL Server类型。

maxLength
Int64

指定类型的最大长度。

precision
Byte

参数或列的精度。

scale
Byte

参数或列的刻度。

locale
Int64

参数或列的区域设置 ID。

compareOptions
SqlCompareOptions

参数或列的比较规则。

userDefinedType
Type

指向 Type UDT 的实例。

例外

name 是 null。

不允许的项 SqlDbType 将传递给构造函数 dbType,或 userDefinedType 指向未 SqlUserDefinedTypeAttribute 声明的类型。

注解

仅允许将以下项传递给构造函数:dbTypeBigInt、、、BitDateTime、FloatDecimal、RealIntNumericImageSmallDateTimeNTextMoneyTimestampTextSmallIntSmallMoneyTinyInt、Udt、。 UniqueIdentifierVariantXml

以下是分配给的默认值,具体取决于 > 和属性设置为 :

SqlDbType最大长度精准率比例尺/规模Locale比较选项
BigInt 81900没有
Bit 1100没有
DateTime 82330没有
Decimal 91800没有
Float 85300没有
Image Max (-1)000没有
Int 41000没有
Money 81940没有
NText Max (-1)00 <thread>IgnoreCase、IgnoreKanaType、IgnoreWidth
Real 42400没有
Row <列数>000没有
SmallDateTime 41600没有
SmallInt 2500没有
SmallMoney 41040没有
Text Max (-1)00 <thread>IgnoreCase、IgnoreKanaType、IgnoreWidth
Timestamp 8000没有
TinyInt 1300没有
UniqueIdentifier 16000没有
Udt <类型> 或 -1 的最大长度000没有
Variant 8016000没有
Xml Max (-1)000IgnoreCase、IgnoreKanaType、IgnoreWidth

适用于

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

Source:
SqlMetaData.cs
Source:
SqlMetaData.cs
Source:
SqlMetaData.cs

使用指定的列名称、类型、数据库名称、拥有架构和对象名称初始化类的新实例 SqlMetaData 。

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.Data.SqlClient.Server.SqlMetaData : string * System.Data.SqlDbType * string * string * string -> Microsoft.Data.SqlClient.Server.SqlMetaData
Public Sub New (name As String, dbType As SqlDbType, database As String, owningSchema As String, objectName As String)

参数

name
String

列的名称。

dbType
SqlDbType

参数或列的SQL Server类型。

database
String

类型化的 XML 实例的 XML 架构集合的数据库名称。

owningSchema
String

类型化的 XML 实例的 XML 架构集合的关系架构名称。

objectName
String

类型化的 XML 实例的 XML 架构集合的名称。

例外

是name,或objectName是null何时database和非owningSchemanull。null

不允许的 SqlDbType 将传递给构造函数。dbType

注解

仅允许将以下内容SqlDbType传递给构造函数:dbType. Xml

以下是分配给 dbType的默认值,具体取决于 SqlDbType:

SqlDbType最大长度精准率比例尺/规模Locale比较选项
Xml Max (-1)000IgnoreCase、IgnoreKanaType、IgnoreWidth

适用于

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

Source:
SqlMetaData.cs
Source:
SqlMetaData.cs
Source:
SqlMetaData.cs

使用指定的列名称、类型、最大长度、区域设置和比较选项初始化类的新实例 SqlMetaData 。

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.Data.SqlClient.Server.SqlMetaData : string * System.Data.SqlDbType * int64 * int64 * System.Data.SqlTypes.SqlCompareOptions -> Microsoft.Data.SqlClient.Server.SqlMetaData
Public Sub New (name As String, dbType As SqlDbType, maxLength As Long, locale As Long, compareOptions As SqlCompareOptions)

参数

name
String

参数或列的名称。

dbType
SqlDbType

参数或列的SQL Server类型。

maxLength
Int64

指定类型的最大长度。

locale
Int64

参数或列的区域设置 ID。

compareOptions
SqlCompareOptions

参数或列的比较规则。

例外

name 是 null。

不允许的项 SqlDbType 作为传递给构造函数 dbType。

注解

仅允许将以下内容传递给构造函数:dbType、、NChar、NVarCharNText、Text。 VarCharChar

仅允许NTextTextdbType或 maxLength -1 的Max规范。

dbType VarChar对于或 NVarChar-1 的长度规范Max,分别将元数据声明为 VARCHAR(MAX) 和 NVARCHAR(MAX)。

以下是分配给的默认值,具体取决于 > 和属性设置为 :

SqlDbType精准率比例尺/规模
Char 00
NChar 00
NText 00
NVarChar 00
Text 00
VarChar 00

适用于

SqlMetaData(String, SqlDbType, Type, String)

Source:
SqlMetaData.cs
Source:
SqlMetaData.cs
Source:
SqlMetaData.cs

使用指定的列名、用户定义的类型(UDT)和SQL Server类型初始化类的新实例SqlMetaData。

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.Data.SqlClient.Server.SqlMetaData : string * System.Data.SqlDbType * Type * string -> Microsoft.Data.SqlClient.Server.SqlMetaData
Public Sub New (name As String, dbType As SqlDbType, userDefinedType As Type, serverTypeName As String)

参数

name
String

列的名称。

dbType
SqlDbType

参数或列的SQL Server类型。

userDefinedType
Type

指向 Type UDT 的实例。

serverTypeName
String

SQL Server类型userDefinedType名称。

适用于

SqlMetaData(String, SqlDbType, Byte, Byte)

Source:
SqlMetaData.cs
Source:
SqlMetaData.cs
Source:
SqlMetaData.cs

使用指定的列名、类型、精度和小数位数初始化类的新实例 SqlMetaData 。

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.Data.SqlClient.Server.SqlMetaData : string * System.Data.SqlDbType * byte * byte -> Microsoft.Data.SqlClient.Server.SqlMetaData
Public Sub New (name As String, dbType As SqlDbType, precision As Byte, scale As Byte)

参数

name
String

参数或列的名称。

dbType
SqlDbType

参数或列的SQL Server类型。

precision
Byte

参数或列的精度。

scale
Byte

参数或列的刻度。

例外

name 是 null。

不允许的项SqlDbType作为或scale大于precision传递给构造函数dbType。

注解

仅允许将以下内容SqlDbType传递给构造函数:dbType. Decimal

以下是分配给的默认值,具体取决于 > 和属性设置为 :

SqlDbType最大长度精准率比例尺/规模Locale比较选项
Decimal 91800没有

适用于

SqlMetaData(String, SqlDbType, Type)

Source:
SqlMetaData.cs
Source:
SqlMetaData.cs
Source:
SqlMetaData.cs

使用指定的列名、类型和用户定义的类型(UDT)初始化类的新实例 SqlMetaData 。

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

参数

name
String

列的名称。

dbType
SqlDbType

参数或列的SQL Server类型。

userDefinedType
Type

指向 Type UDT 的实例。

例外

name 是 null。

不允许的项 SqlDbType 将传递给构造函数 dbType,或 userDefinedType 指向未 SqlUserDefinedTypeAttribute 声明的类型。

注解

仅允许将以下内容SqlDbType传递给构造函数:dbType. Udt

以下是分配给的默认值,具体取决于 > 和属性设置为 :

SqlDbType最大长度精准率比例尺/规模Locale比较选项
Udt <类型> 或 -1 的最大长度000没有

适用于

SqlMetaData(String, SqlDbType, Int64)

Source:
SqlMetaData.cs
Source:
SqlMetaData.cs
Source:
SqlMetaData.cs

使用指定的列名、类型和最大长度初始化类的新实例 SqlMetaData 。

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

参数

name
String

列的名称。

dbType
SqlDbType

参数或列的SQL Server类型。

maxLength
Int64

指定类型的最大长度。

例外

name 是 null。

不允许的 SqlDbType 将传递给构造函数。dbType

示例

以下示例通过指定列名、列数据类型NVarChar和最大长度为 12 个字符来SqlMetaData创建新对象。

using Microsoft.Data.SqlClient.Server;

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

注解

仅允许将以下项传递给构造函数:dbType、、、CharNVarCharImageNTextNChar、 Text、。 VarBinaryVarCharBinary

只有一个maxLength或 -1 的规范Max允许 NTextdbTypeTextImage或 -1。

dbType VarChar对于 、NVarChar或 VarBinary-1 的长度规范Max,分别将元数据声明为VARCHAR(MAX)、NVARCHAR(MAX)或 NVARBINARY(MAX)-1。

以下是分配给的默认值,具体取决于 > 和属性设置为 :

SqlDbType精准率比例尺/规模Locale比较选项
Binary 000IgnoreCase、IgnoreKanaType、IgnoreWidth
Char 00 <thread>IgnoreCase、IgnoreKanaType、IgnoreWidth
Image 000没有
NChar 00 <thread>IgnoreCase、IgnoreKanaType、IgnoreWidth
NText 00 <thread>IgnoreCase、IgnoreKanaType、IgnoreWidth
NVarChar 00 <thread>IgnoreCase、IgnoreKanaType、IgnoreWidth
Text 00 <thread>IgnoreCase、IgnoreKanaType、IgnoreWidth
VarBinary 00IgnoreCase、IgnoreKanaType、IgnoreWidth
VarChar 00 <thread>IgnoreCase、IgnoreKanaType、IgnoreWidth

适用于

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

Source:
SqlMetaData.cs
Source:
SqlMetaData.cs
Source:
SqlMetaData.cs

使用指定的列名和默认服务器初始化类的新实例 SqlMetaData 。 这种形式的构造函数支持表值参数,即允许指定列在表值参数中是否唯一、该列的排序顺序以及排序列的序号。

public:
 SqlMetaData(System::String ^ name, System::Data::SqlDbType dbType, bool useServerDefault, bool isUniqueKey, Microsoft::Data::SqlClient::SortOrder columnSortOrder, int sortOrdinal);
public SqlMetaData(string name, System.Data.SqlDbType dbType, bool useServerDefault, bool isUniqueKey, Microsoft.Data.SqlClient.SortOrder columnSortOrder, int sortOrdinal);
new Microsoft.Data.SqlClient.Server.SqlMetaData : string * System.Data.SqlDbType * bool * bool * Microsoft.Data.SqlClient.SortOrder * int -> Microsoft.Data.SqlClient.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

列的名称。

dbType
SqlDbType

参数或列的SQL Server类型。

useServerDefault
Boolean

指定此列是否应使用默认服务器值。

isUniqueKey
Boolean

指定表值参数中的列是否唯一。

columnSortOrder
SortOrder

指定列的排序顺序。

sortOrdinal
Int32

指定排序列的序号。

注解

有关详细信息,请参阅 Table-Valued 参数。

适用于