IListManager::ExportToSql

Ee826037.c++_off(en-US,CS.10).gifEe826037.vb_on(en-US,CS.10).gif

Use this method to export a list to the specified table in a Microsoft SQL Server database. This operation can be performed synchronously or asynchronously.

Definition

HRESULT IListManager::ExportToSql(VARIANTlistID,BSTRconnStr,BSTRresTable,BOOLbOverwrite,longlOptions,BOOLbAsync,VARIANT*pvarOpID);

Parameters

listID

[in] A VARIANT that contains the ID or name of the list to be exported.

connStr

[in] A BSTR that contains the connection string for the SQL Server database.

resTable

[in] A BSTR that contains the name of the table into which the list will be exported.

bOverwrite

[in] A BOOL that specifies whether to overwrite the data if the table already exists. A value of True indicates that the data should be overwritten. A value of False produces an error if the tables already exist.

lOptions

[in] A long that specifies the export options for use by the Direct Mail resource. Other applications should generally pass the value zero (0). A value of one (1) causes special action to be taken. See the Remarks section below.

bAsync

[in] A BOOL that specifies whether the creation operation is performed synchronously or asynchronously. A value of True indicates asynchronous processing. A value of False indicates synchronous processing.

pvarOpID

[out, optional] A pointer to a VARIANT used to return an Operation ID. This Operation ID is used in subsequent processing concerning this operation.

Return Values

This method returns an HRESULT indicating whether it completed successfully. See the Error Values section for more details.

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_LM_CONNECTIONFAILED 0x8C400001 Failed to establish database connection.
E_LM_LIST_BUSY 0x8C400008 The specified list is currently busy with another operation.
E_LM_LIST_IN_FAILED_STATE 0x8C40001D The specified list is in a FAILED state and may not be used for the operation.
E_LM_LIST_NOT_FOUND 0x8C400006 The specified list does not exist.
E_LM_OPER_CANCELED 0x8C40000B The operation was canceled.
E_LM_SQLERROR 0x8C400003 Error while executing SQL/ADO operation.
E_LM_TABLE_ALREADY_EXISTS 0x8C40000F The specified table cannot be created because it already exists.
OLE_E_BLANK 0x80040007 The ListManager object has not been properly initialized.

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

An existing table is expected to have the same format as the exported list. If the table does not exist, it will be created.

The ExportToSQL method works by opening a connection on the destination SQL Server database and executing the T-SQL OpenRowset command to select data from the List Manager database. Because of this, some special caveats apply:

  • The destination database must have the Bulk Copy/Select Into option selected.

  • If the List Manager was initialized with a connection string containing a DSN then the SQL server computer hosting the destination database must also have the DSN configured.

  • Unlike the CreateFromSQL command, ODBC data sources other than SQL Server 7.0 or greater are not supported.

The parameter pvarOpID contains valid data only if the export operation is performed asynchronously.

The lOptions parameter specifies whether the exported list is intended for use with Direct Mailer, controlling how it is processed during the export. The following table shows the legal values of the IOptions parameter.

lOptions value Description
0 Do not do any special processing for Direct Mailer.
1 Export the list for use with Direct Mailer. The list must be a Mailable list or an error is returned. If the list is not a mailing list, it is converted to one.

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

See Also

ListManager Object

IListManager::ExtractMailingList


All rights reserved.