Share via


ICatalogManager::ImportCSV

Ee824931.c++_off(en-US,CS.10).gifEe824931.vb_on(en-US,CS.10).gif

Use this method to import a comma-separated-value (CSV) format file as catalog data.

Definition

HRESULT ICatalogManager::ImportCSV(BSTRstrCSVFileSource,BSTRstrProductIDColumnName,BSTRstrPriceColumnName,BSTRstrCatalogName,VARIANT_BOOLfUpdateOnlyVARIANT_BOOLfRunSynchronously);

Parameters

strCSVFileSource

[in] A BSTR that contains the path and file name of the CSV file to import.

strProductIDColumnName

[in] A BSTR that contains the name of the column that provides a unique ID for products to be imported into the catalog.

strPriceColumnName

[in] A BSTR that contains the name of the column in the CSV file containing the product prices.

strCatalogName

[in] A BSTR that contains the name of the catalog into which the CSV file will be imported. The name of the catalog cannot begin with "#" or consist solely of spaces.

fUpdateOnly

[in, defaultvalue (0)] A VARIANT_BOOL that specifies whether to update an existing catalog or create a new one. A value of True indicates that if the system contains a catalog whose name is the same as the one specified in the strCatalogName parameter, it will be updated with the imported data. A value of False indicates to delete the catalog if it already exists and create a new one with the imported data.

fRunSynchronously

[in, defaultvalue (0)] A VARIANT_BOOL that specifies whether the method should be run synchronously. A value of True indicates that the method will not return until the import is completed. A value of False indicates that the method will return immediately after spawning the import thread.

Return Values

This method returns an HRESULT indicating it completed successfully.

Error Values

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.

The following table shows the custom COM errors that this method can return.

Constant Value Description
E_CAT_IMPORT_IN_PROGRESS 0x88980025 There was an existing import method call that had not yet completed. This method cannot run while an import is in progress.
E_CAT_FILE_OPEN_ERROR 0x88980020 The method was unable to open the file.

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.

Remarks

If the parameter strCatalogName specifies a catalog that does not exist, a new catalog will be created and the value of the fUpdateOnly parameter is ignored.

The ImportCSV method is used to bring existing data from a wide variety of sources into the Product Catalog System. The CSV file must conform to the following format:

  • The first row of data consists of column names, separated by commas. Rows are delimited by new lines in the text file.

  • Each subsequent row (called a data row) must have the same number of commas as the very first row. In other words, all columns in the CSV must be defined by the first row.

  • All items in the CSV file (one row per item) are assumed to be products, and are created from a common product definition. If no product definition exists in the destination catalog then one will be created during the import process.

  • Each item must specify a value for the column specified as the ProductID column, as well as for the column specified as the Price column.

  • Missing data is represented my two adjacent commas.

Ee824931.note(en-US,CS.10).gifNotes

  • This method runs in a separate thread. Prior to spawning the thread, it checks that the specified file can be opened and that there is not an existing ExportCSV, ExportXML, ImportCSV or ImportXML method in progress. Once the new thread is spawned, this method returns immediately, if fRunSynchronously is False, with no errors. Any errors that occurred while importing the catalog are logged to the Windows NT Event Log. Use the Windows Event Viewer to view the Windows NT Event Log.

  • This method cannot be called in a transacted object. This method involves the creation, deletion, or updating of free text indexes. SQL Server does not allow these operations in a transaction.

  • If there is a temporary loss of the SQL connection, longer than two minutes, an import or export will be aborted. Other methods should work after the interruption.

For more information about memory ownership issues related to COM property and method parameters, see Managing COM Parameter Memory.

See Also

CatalogManager Object

ICatalogManager::ExportCSV

ICatalogManager::ImportXML


All rights reserved.