SqlMetaData Constructor (String, SqlDbType, Int64)
Initializes a new instance of the SqlMetaData class with the specified column name, type, and maximum length.
Assembly: System.Data (in System.Data.dll)
Parameters
- name
- Type: System::String
The name of the column.
- dbType
- Type: System.Data::SqlDbType
The SQL Server type of the parameter or column.
- maxLength
- Type: System::Int64
The maximum length of the specified type.
| Exception | Condition |
|---|---|
| ArgumentNullException | The Name is nullptr. |
| ArgumentException | A SqlDbType that is not allowed was passed to the constructor as dbType. |
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 nullptr):
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 |
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.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.