SqlMetaData Constructors
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.
Overloads
SqlMetaData(String, SqlDbType) |
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) |
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) |
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) |
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) |
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) |
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) |
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) |
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) |
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) |
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) |
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) |
Initializes a new instance of the SqlMetaData class with the specified column name, type, precision, and scale. |
SqlMetaData(String, SqlDbType, Type) |
Initializes a new instance of the SqlMetaData class with the specified column name, type, and user-defined type (UDT). |
SqlMetaData(String, SqlDbType, Int64) |
Initializes a new instance of the SqlMetaData class with the specified column name, type, and maximum length. |
SqlMetaData(String, SqlDbType, Boolean, Boolean, SortOrder, Int32) |
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)
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.Data.SqlClient.Server.SqlMetaData : string * System.Data.SqlDbType -> Microsoft.Data.SqlClient.Server.SqlMetaData
Public Sub New (name As String, dbType As SqlDbType)
Parameters
- name
- String
The name of the column.
- dbType
- SqlDbType
The SQL Server type of the parameter or column.
Exceptions
The name
is null
.
A SqlDbType
that is not allowed was passed to the constructor as dbType
.
Examples
The following example creates a new SqlMetaData object by specifying the column name and a column data type of SqlDbType.Int
.
// using Microsoft.Data.SqlClient.Server;
public static void CreateSqlMetaData2()
{
SqlMetaData columnInfo;
columnInfo = new SqlMetaData("Column2", SqlDbType.Int);
}
Remarks
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
.
The following are the default values assigned to dbType
, depending on the SqlDbType
(the XmlSchemaCollectionDatabase, XmlSchemaCollectionName, XmlSchemaCollectionOwningSchema, and Type properties are set to null
):
SqlDbType | Maximum length | Precision | Scale | Locale | Compare options |
---|---|---|---|---|---|
Bit |
1 | 1 | 0 | 0 | None |
BigInt |
8 | 19 | 0 | 0 | None |
DateTime |
8 | 23 | 3 | 0 | None |
Decimal |
9 | 18 | 0 | 0 | None |
Float |
8 | 53 | 0 | 0 | None |
Int |
4 | 10 | 0 | 0 | None |
Money |
8 | 19 | 4 | 0 | None |
Numeric |
9 | 18 | 0 | 0 | None |
SmallDateTime |
4 | 16 | 0 | 0 | None |
SmallInt |
2 | 5 | 0 | 0 | None |
SmallMoney |
4 | 10 | 4 | 0 | None |
TimeStamp |
8 | 0 | 0 | 0 | None |
TinyInt |
1 | 3 | 0 | 0 | None |
UniqueIdentifier |
16 | 0 | 0 | 0 | None |
Xml |
Max (-1) | 0 | 0 | 0 | IgnoreCase, IgnoreKanaType, IgnoreWidth |
Applies to
SqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type, Boolean, Boolean, SortOrder, Int32)
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, 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)
Parameters
- name
- String
The name of the column.
- dbType
- SqlDbType
The SQL Server type of the parameter or column.
- maxLength
- Int64
The maximum length of the specified type.
- precision
- Byte
The precision of the parameter or column.
- scale
- Byte
The scale of the parameter or column.
- localeId
- Int64
The locale ID of the parameter or column.
- compareOptions
- SqlCompareOptions
The comparison rules of the parameter or column.
- useServerDefault
- Boolean
Specifies whether this column should use the default server value.
- isUniqueKey
- Boolean
Specifies if the column in the table-valued parameter is unique.
- columnSortOrder
- SortOrder
Specifies the sort order for a column.
- sortOrdinal
- Int32
Specifies the ordinal of the sort column.
Remarks
For more information, see Table-Valued Parameters.
Applies to
SqlMetaData(String, SqlDbType, String, String, String, Boolean, Boolean, SortOrder, Int32)
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, 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)
Parameters
- name
- String
The name of the column.
- dbType
- SqlDbType
The SQL Server type of the parameter or column.
- database
- String
The database name of the XML schema collection of a typed XML instance.
- owningSchema
- String
The relational schema name of the XML schema collection of a typed XML instance.
- objectName
- String
The name of the XML schema collection of a typed XML instance.
- useServerDefault
- Boolean
Specifies whether this column should use the default server value.
- isUniqueKey
- Boolean
Specifies if the column in the table-valued parameter is unique.
- columnSortOrder
- SortOrder
Specifies the sort order for a column.
- sortOrdinal
- Int32
Specifies the ordinal of the sort column.
Remarks
For more information, see Table-Valued Parameters.
Applies to
SqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions, Boolean, Boolean, SortOrder, Int32)
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, 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)
Parameters
- name
- String
The name of the column.
- dbType
- SqlDbType
The SQL Server type of the parameter or column.
- maxLength
- Int64
The maximum length of the specified type.
- locale
- Int64
The locale ID of the parameter or column.
- compareOptions
- SqlCompareOptions
The comparison rules of the parameter or column.
- useServerDefault
- Boolean
Specifies whether this column should use the default server value.
- isUniqueKey
- Boolean
Specifies if the column in the table-valued parameter is unique.
- columnSortOrder
- SortOrder
Specifies the sort order for a column.
- sortOrdinal
- Int32
Specifies the ordinal of the sort column.
Remarks
For more information, see Table-Valued Parameters.
Applies to
SqlMetaData(String, SqlDbType, Type, String, Boolean, Boolean, SortOrder, Int32)
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, 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)
Parameters
- name
- String
The name of the column.
- dbType
- SqlDbType
The SQL Server type of the parameter or column.
- serverTypeName
- String
The SQL Server type name for userDefinedType
.
- useServerDefault
- Boolean
Specifies whether this column should use the default server value.
- isUniqueKey
- Boolean
Specifies if the column in the table-valued parameter is unique.
- columnSortOrder
- SortOrder
Specifies the sort order for a column.
- sortOrdinal
- Int32
Specifies the ordinal of the sort column.
Remarks
For more information, see Table-Valued Parameters.
Applies to
SqlMetaData(String, SqlDbType, Byte, Byte, Boolean, Boolean, SortOrder, Int32)
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, 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)
Parameters
- name
- String
The name of the column.
- dbType
- SqlDbType
The SQL Server type of the parameter or column.
- precision
- Byte
The precision of the parameter or column.
- scale
- Byte
The scale of the parameter or column.
- useServerDefault
- Boolean
Specifies whether this column should use the default server value.
- isUniqueKey
- Boolean
Specifies if the column in the table-valued parameter is unique.
- columnSortOrder
- SortOrder
Specifies the sort order for a column.
- sortOrdinal
- Int32
Specifies the ordinal of the sort column.
Remarks
For more information, see Table-Valued Parameters.
Applies to
SqlMetaData(String, SqlDbType, Int64, Boolean, Boolean, SortOrder, Int32)
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, 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)
Parameters
- name
- String
The name of the column.
- dbType
- SqlDbType
The SQL Server type of the parameter or column.
- maxLength
- Int64
The maximum length of the specified type.
- useServerDefault
- Boolean
Specifies whether this column should use the default server value.
- isUniqueKey
- Boolean
Specifies if the column in the table-valued parameter is unique.
- columnSortOrder
- SortOrder
Specifies the sort order for a column.
- sortOrdinal
- Int32
Specifies the ordinal of the sort column.
Remarks
For more information, see Table-Valued Parameters.
Applies to
SqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type)
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.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)
Parameters
- name
- String
The name of the column.
- dbType
- SqlDbType
The SQL Server type of the parameter or column.
- maxLength
- Int64
The maximum length of the specified type.
- precision
- Byte
The precision of the parameter or column.
- scale
- Byte
The scale of the parameter or column.
- locale
- Int64
The locale ID of the parameter or column.
- compareOptions
- SqlCompareOptions
The comparison rules of the parameter or column.
Exceptions
The name
is null
.
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
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
.
The following are the default values assigned to dbType
, depending on the SqlDbType
(the XmlSchemaCollectionDatabase, XmlSchemaCollectionName, XmlSchemaCollectionOwningSchema, and Type properties are set to null
):
SqlDbType | Maximum length | Precision | Scale | Locale | Compare options |
---|---|---|---|---|---|
BigInt |
8 | 19 | 0 | 0 | None |
Bit |
1 | 1 | 0 | 0 | None |
DateTime |
8 | 23 | 3 | 0 | None |
Decimal |
9 | 18 | 0 | 0 | None |
Float |
8 | 53 | 0 | 0 | None |
Image |
Max (-1) | 0 | 0 | 0 | None |
Int |
4 | 10 | 0 | 0 | None |
Money |
8 | 19 | 4 | 0 | None |
Ntext |
Max (-1) | 0 | 0 | <thread> | IgnoreCase, IgnoreKanaType, IgnoreWidth |
Real |
4 | 24 | 0 | 0 | None |
Row |
<number of columns> | 0 | 0 | 0 | None |
SmallDateTime |
4 | 16 | 0 | 0 | None |
SmallInt |
2 | 5 | 0 | 0 | None |
SmallMoney |
4 | 10 | 4 | 0 | None |
Text |
Max (-1) | 0 | 0 | <thread> | IgnoreCase, IgnoreKanaType, IgnoreWidth |
TimeStamp |
8 | 0 | 0 | 0 | None |
TinyInt |
1 | 3 | 0 | 0 | None |
UniqueIdentifier |
16 | 0 | 0 | 0 | None |
UDT |
<Max length of the type> or -1 | 0 | 0 | 0 | None |
Variant |
8016 | 0 | 0 | 0 | None |
Xml |
Max (-1) | 0 | 0 | 0 | IgnoreCase, IgnoreKanaType, IgnoreWidth |
Applies to
SqlMetaData(String, SqlDbType, String, String, String)
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.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)
Parameters
- name
- String
The name of the column.
- dbType
- SqlDbType
The SQL Server type of the parameter or column.
- database
- String
The database name of the XML schema collection of a typed XML instance.
- owningSchema
- String
The relational schema name of the XML schema collection of a typed XML instance.
- objectName
- String
The name of the XML schema collection of a typed XML instance.
Exceptions
The name
is null
, or objectName
is null
when database
and owningSchema
are non-null
.
A SqlDbType that is not allowed was passed to the constructor as dbType
.
Remarks
Only the following SqlDbType
is allowed to be passed to the constructor as dbType
: Xml
.
The following are the default values assigned to dbType
, depending on the SqlDbType
:
SqlDbType | Maximum length | Precision | Scale | Locale | Compare options |
---|---|---|---|---|---|
Xml |
Max (-1) | 0 | 0 | 0 | IgnoreCase, IgnoreKanaType, IgnoreWidth |
Applies to
SqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions)
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.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)
Parameters
- name
- String
The name of the parameter or column.
- dbType
- SqlDbType
The SQL Server type of the parameter or column.
- maxLength
- Int64
The maximum length of the specified type.
- locale
- Int64
The locale ID of the parameter or column.
- compareOptions
- SqlCompareOptions
The comparison rules of the parameter or column.
Exceptions
The name
is null
.
A SqlDbType that is not allowed was passed to the constructor as dbType
.
Remarks
Only the following are allowed to be passed to the constructor as dbType
: Char
, NChar
, Ntext
, NVarChar
, Text
, VarChar
.
Only a maxLength
specification of Max, or -1, is allowed for a dbType
of Text
or NText
.
For a dbType
of Varchar
or Nvarchar
, a length specification of Max, or -1, declares the metadata as varchar(max) and nvarchar(max), respectively.
The following are the default values assigned to dbType
, depending on the SqlDbType
(the XmlSchemaCollectionDatabase, XmlSchemaCollectionName, XmlSchemaCollectionOwningSchema, and Type properties are set to null
):
SqlDbType | Precision | Scale |
---|---|---|
Char |
0 | 0 |
NChar |
0 | 0 |
NText |
0 | 0 |
NVarChar |
0 | 0 |
Text |
0 | 0 |
VarChar |
0 | 0 |
Applies to
SqlMetaData(String, SqlDbType, Type, String)
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.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)
Parameters
- name
- String
The name of the column.
- dbType
- SqlDbType
The SQL Server type of the parameter or column.
- serverTypeName
- String
The SQL Server type name for userDefinedType
.
Applies to
SqlMetaData(String, SqlDbType, Byte, Byte)
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.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)
Parameters
- name
- String
The name of the parameter or column.
- dbType
- SqlDbType
The SQL Server type of the parameter or column.
- precision
- Byte
The precision of the parameter or column.
- scale
- Byte
The scale of the parameter or column.
Exceptions
The name
is null
.
A SqlDbType
that is not allowed was passed to the constructor as dbType
, or scale
was greater than precision
.
Remarks
Only the following SqlDbType
is allowed to be passed to the constructor as dbType
: Decimal
.
The following are the default values assigned to dbType
, depending on the SqlDbType
(the XmlSchemaCollectionDatabase, XmlSchemaCollectionName, XmlSchemaCollectionOwningSchema, and Type properties are set to null
):
SqlDbType | Maximum length | Precision | Scale | Locale | Compare options |
---|---|---|---|---|---|
Decimal | 9 | 18 | 0 | 0 | None |
Applies to
SqlMetaData(String, SqlDbType, Type)
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.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)
Parameters
- name
- String
The name of the column.
- dbType
- SqlDbType
The SQL Server type of the parameter or column.
Exceptions
The name
is null
.
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
Only the following SqlDbType
is allowed to be passed to the constructor as dbType
: UDT
.
The following are the default values assigned to dbType
, depending on the SqlDbType
(the XmlSchemaCollectionDatabase, XmlSchemaCollectionName, XmlSchemaCollectionOwningSchema, and Type properties are set to null
):
SqlDbType | Maximum length | Precision | Scale | Locale | Compare options |
---|---|---|---|---|---|
UDT | <Max length of the type> or -1 | 0 | 0 | 0 | None |
Applies to
SqlMetaData(String, SqlDbType, Int64)
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.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)
Parameters
- name
- String
The name of the column.
- dbType
- SqlDbType
The SQL Server type of the parameter or column.
- maxLength
- Int64
The maximum length of the specified type.
Exceptions
The name
is null
.
A SqlDbType that is not allowed was passed to the constructor as dbType
.
Examples
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.
// using Microsoft.Data.SqlClient.Server;
public static void CreateSqlMetaData1()
{
SqlMetaData columnInfo;
columnInfo = new SqlMetaData("Column1", SqlDbType.NVarChar, 12);
}
Remarks
Only the following are allowed to be passed to the constructor as dbType
: Binary
, Char
, Image
, NChar
, Ntext
, NVarChar
, Text
, VarBinary
, VarChar
.
Only a maxLength
specification of Max, or -1 is allowed for a dbType
of Text
, NText
, or Image
.
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.
The following are the default values assigned to dbType
, depending on the SqlDbType
(the XmlSchemaCollectionDatabase, XmlSchemaCollectionName, XmlSchemaCollectionOwningSchema, and Type properties are set to null
):
SqlDbType | Precision | Scale | Locale | Compare options |
---|---|---|---|---|
Binary | 0 | 0 | 0 | IgnoreCase, IgnoreKanaType, IgnoreWidth |
Char | 0 | 0 | <thread> | IgnoreCase, IgnoreKanaType, IgnoreWidth |
Image | 0 | 0 | 0 | None |
NChar | 0 | 0 | <thread> | IgnoreCase, IgnoreKanaType, IgnoreWidth |
NText | 0 | 0 | <thread> | IgnoreCase, IgnoreKanaType, IgnoreWidth |
NVarChar | 0 | 0 | <thread> | IgnoreCase, IgnoreKanaType, IgnoreWidth |
Text | 0 | 0 | <thread> | IgnoreCase, IgnoreKanaType, IgnoreWidth |
VarBinary | 0 | 0 | IgnoreCase, IgnoreKanaType, IgnoreWidth | |
VarChar | 0 | 0 | <thread> | IgnoreCase, IgnoreKanaType, IgnoreWidth |
Applies to
SqlMetaData(String, SqlDbType, Boolean, Boolean, SortOrder, Int32)
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, 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)
Parameters
- name
- String
The name of the column.
- dbType
- SqlDbType
The SQL Server type of the parameter or column.
- useServerDefault
- Boolean
Specifies whether this column should use the default server value.
- isUniqueKey
- Boolean
Specifies if the column in the table-valued parameter is unique.
- columnSortOrder
- SortOrder
Specifies the sort order for a column.
- sortOrdinal
- Int32
Specifies the ordinal of the sort column.
Remarks
For more information, see Table-Valued Parameters.