Share via


ListManager.ExportToSql

Ee784597.c++_on(en-US,CS.10).gifEe784597.vb_off(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

Sub ExportToSql(listID As Variant,connStr As String,resTable As String,bOverwrite As Boolean,lOptions As Long,bAsync As Boolean,Optional pvarOpID As Variant)

Parameters

listID

A Variant that contains the ID or name of the list to be exported.

connStr

A String that contains the connection string for the SQL Server database.

resTable

A String that contains the name of the table into which the list will be exported.

bOverwrite

A Boolean that specifies whether to overwrite the data in the table 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 pre-exists.

lOptions

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

A Boolean 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

An optional Variant used to return an Operation ID. This Operation ID is used in subsequent processing concerning this operation.

Error Values

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.

Constant Value Description
E_LM_CONNECTIONFAILED &H8C400001 Failed to establish database connection.
E_LM_LIST_BUSY &H8C400008 The specified list is currently busy with another operation.
E_LM_LIST_IN_FAILED_STATE &H8C40001D The specified list is in a FAILED state and may not be used for the operation.
E_LM_LIST_NOT_FOUND &H8C400006 The specified list does not exist.
E_LM_OPER_CANCELED &H8C40000B The operation was canceled.
E_LM_SQLERROR &H8C400003 Error while executing SQL/ADO operation.
E_LM_TABLE_ALREADY_EXISTS &H8C40000F The specified table cannot be created because it already exists.
OLE_E_BLANK &H80040007 The ListManager object has not been properly initialized.

Additional information may be available using the global Err object. In particular, the Description property may contain 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.

Example

oListManager.ExportToSql "{2B544800-4169-4C49-8713-1B794078B4C9}", _ "Provider=sqloledb;Data Source=TequillaServer;" & _ "Initial Catalog=Margaritas;User=userid;Password=******", _ "Tequila", False, 0, False

See Also

ListManager Object

ListManager.ExtractMailingList


All rights reserved.