ICatalogManager3::AddCatalogAttribute Method[C++]
Use this method to add an attribute to a catalog.
Definition
[C++]
HRESULT ICatalogManager3::AddCatalogAttribute(BSTRstrAttributeName,
CatalogDataTypeEnumeDataType,
VARIANTvarMaxLength);
[Visual Basic]
Sub AddCatalogAttribute(strAttributeName As String,
eDataType As CatalogDataTypeEnum,
Optional varMaxLength As Variant)
Parameters
- strAttributeName[C++]
[in] A BSTR that contains the attribute name. See the Remarks section for a list of restricted characters. - strAttributeName[Visual Basic]
A String that contains the attribute name. See the Remarks section for a list of restricted characters. - eDataType[C++]
[in] An enumeration that contains the data type. See the Remarks section for valid values. - eDataType[Visual Basic]
An enumeration that contains the data type. See the Remarks section for valid values. - varMaxLength[C++]
[in, optional] A VARIANT that contains the maximum string length if the eDataType parameter is cscString. This parameter is required if the eDataType parameter is cscString. - varMaxLength[Visual Basic]
A VARIANT that contains the maximum string length if the eDataType parameter is cscString. This parameter is required if the eDataType parameter is cscString.
Return Values
[C++] This method returns an HRESULT indicating whether it completed successfully. See the Error Values section for more details.
[Visual Basic] None.
Error Values
[C++] This method returns S_OK (0x00000000) to indicate success and either standard or custom COM HRESULT error values to indicate failure. For more information about standard COM errors, see Standard COM Errors.
[Visual Basic] This method sets the Number property of the global Err object to S_OK (&H00000000) to indicate success and to either standard or custom COM error values to indicate failure. For more information about standard COM errors, see Standard COM Errors.
The following table shows the custom COM errors that this method can return.
Name | Value | Description |
---|---|---|
E_CAT_CATMGR_NOT_INITIALIZED | [C++] 0x889800B5 [Visual Basic] &H889800B5 |
The CatalogManager object has not been initialized. The CatalogManager object should be initialized before calling this method. |
E_CAT_INVALID_ATTRIBUTE | [C++] 0x88980117 [Visual Basic] &H88980117 |
The attribute name you specified is invalid. Attribute names cannot be blank and cannot exceed 36 characters. Attribute names cannot begin with a digit and cannot contain one of the following five reserved characters .,"[] |
E_CAT_INVALID_DATATYPE | [C++] 0x88980074 [Visual Basic] &H88980074 |
The datatype you specified is invalid. |
E_CAT_INVALID_PARAMETER | [C++] 0x889800B6 [Visual Basic] &H889800B6 |
The input parameter <parameter number> is invalid. |
E_CAT_INVALID_COLUMN_LENGTH | [C++] 0x88980040 [Visual Basic] &H88980040 |
The length specified for this property does not lie between 1 and 4000. |
E_CAT_INVALID_DATATYPE_FOR_ATTRIBUTE | [C++] 0x889800A6 [Visual Basic] &H889800A6 |
The enumeration or filename data types cannot be used for creating property attributes |
E_CAT_BUILTIN_CATALOG_ATTRIBUTE | [C++] 0x889800B0 [Visual Basic] &H889800B0 |
The catalog attribute that you specified is a built in catalog attribute and hence cannot be added or removed. |
E_CAT_INVALID_DATATYPE | [C++] 0x88980074 [Visual Basic] &H88980074 |
The datatype you specified is invalid. |
E_CAT_MAX_ATTRIBUTES | [C++] 0x88980118 [Visual Basic] &H88980118 |
You have exceeded the maximum limit of 100 attributes that can be created |
E_CAT_CATALOG_ATTR_EXISTS | [C++] 0x88980110 [Visual Basic] &H88980110 |
The catalog attribute that you specified already exists. |
[C++] Additional information may be available using the global Err object, which can be accessed using the API function GetErrorInfo. In particular, the GetDescription method of the IErrorInfo interface may return a text description of the error.
[Visual Basic] Additional information may be available using the global Err object. In particular, the Description property may contain a text description of the error.
Remarks
The varMaxLength parameter applies only when the eDataType parameter equals cscString. The minimum value is 1 and the maximum value is 4000. The varMaxLength parameter is ignored for all other data types.
Each catalog system is limited to 100 attributes.
Catalog attribute names, and therefore the strAttributeName parameter, are limited to a maximum length of 36 characters and cannot contain any of the following characters:
- Period (.)
- Comma (,)
- Double quote (")
- Left square bracket ([)
- Right square bracket (])
The following table shows the values of the CatalogDataTypeEnum enumeration that are valid for this method, their associated names, and describes their use.
Name | Value | Description |
---|---|---|
cscInteger | 0 | Indicates an exact numeric value that holds whole numbers from –2[31] (-2,147,483,648) <= n <= 2[31] –1 (2,147,483,647). |
cscBigInteger | 1 | Indicates an exact numeric value with precision 19 (if signed) or 20 (if unsigned), and scale 0 (signed: –2[63] <= n <= 2[63] – 1, unsigned: 0 <= n <= 2[64] – 1) [3], [9]. |
cscFloat | 2 | Indicates a positive or negative floating-point number. The range of positive values is approximately 2.23E –308 through 1.79E 308, and the range of negative values is approximately –2.23E –308 through –1.79E 308. |
cscDouble | 3 | Indicates a positive or negative floating-point number. The range of positive values is approximately 2.23E –308 through 1.79E 308, and the range of negative values is approximately –2.23E –308 through –1.79E 308. |
cscBoolean | 4 | Indicates a Boolean (bit), holds either a 1 or 0. Integer values other than 1 or 0 are accepted but are always interpreted as 1. |
cscString | 5 | Indicates a variable-length character string with a maximum string length of 4000 characters. |
cscDateTime | 6 | Indicates a Microsoft SQL Server DateTime data type. |
cscCurrency | 7 | Indicates a Microsoft SQL Server money data type. |
cscText | 10 | Indicates a Microsoft SQL Server NText data type. |
cscInvalid | -1 | Reserved for future use. |
For more information about memory ownership issues related to COM property and method parameters, see Managing COM Parameter Memory.
[Visual Basic]
Example
myCatalogManager.AddCatalogAttribute("Supplier", cscString, 100)
See Also
User-defined Property and Catalog Attributes
[Visual Basic]CatalogManager Object
Copyright © 2005 Microsoft Corporation.
All rights reserved.