ListManager.CreateFromSql Method (PIA)

Use this method to create a list from an SQL query.

Definition

[Visual Basic .NET]

Imports Microsoft.CommerceServer.Interop.Targeting
…
Public Function CreateFromSql(listName As String,
 listDesc As String,
 lFlags As Integer,
 userFlags As Integer,
 connStr As String,
 queryStr As String,
 errLimit As Integer,
 bAsync As Integer,
 Optional ByRefpvarOpID As Object) As Object

[C#]

using Microsoft.CommerceServer.Interop.Targeting;
…
public object CreateFromSql(stringlistName,
 stringlistDesc,
 intlFlags,
 intuserFlags,
 stringconnStr,
 stringqueryStr,
 interrLimit,
 int bAsync,
 ref objectpvarOpID);

Parameters

[Visual Basic .NET]

  • listName
    A String that provides the name for the list.
  • listDesc
    A String that provides a description for the list.
  • lFlags
    An Integer that specifies the bitmask flags that control the type of list created.
  • userFlags
    An Integer that contains application-specific user flags. Not used by the ListManager object.
  • connStr
    A String that contains the connection string for the SQL Server database.
  • queryStr
    A String that contains the SQL query for retrieving the contents of the new list.
  • errLimit
    An Integer that is not used.
  • bAsync
    An Integer that specifies whether the creation operation is performed synchronously or asynchronously. A value of 1 indicates asynchronous processing.
  • pvarOpID
    An optional Object used to return an Operation ID.

[C#]

  • listName
    A string that provides the name for the list.
  • listDesc
    A string that provides a description for the list.
  • lFlags
    An int that specifies the bitmask flags that control the type of list created.
  • userFlags
    An int that contains application-specific user flags. Not used by the ListManager object.
  • connStr
    A string that contains the connection string for the SQL Server database.
  • queryStr
    A string that contains the SQL query for retrieving the contents of the new list.
  • errLimit
    An int that is not used.
  • bAsync
    An int that specifies whether the creation operation is performed synchronously or asynchronously. A value of 1 indicates asynchronous processing.
  • pvarOpID
    A reference to an object used to return an Operation ID.

Return Values

[Visual Basic .NET] If this method completes successfully, it returns an Object that contains the ID of the new list.

[C#] This method returns a reference to an object used to return the ID of the new list.

Exceptions

This method may throw one of many mapped exceptions or an exception of type COMException. See Standard COM Errors for additional details.

[Visual Basic .NET]

The following table shows the custom COM errors that a COMException can wrap.

Value Description
&H8C400001 Failed to establish database connection.
&H8C400005 Invalid flags value.
&H8C400007 The specified list has already been created.
&H8C40000D The list is designated as a Mailable list but does not contain an rcp_email column.
&H8C40000B The operation was canceled.
&H8C400003 Error while executing SQL/ADO operation.
&H8C40000E The list is designated as a User list but does not contain an rcp_guid column.
&H80040007 The ListManager object has not been properly initialized.

[C#]

The following table shows the custom COM errors that a COMException can wrap.

Value Description
0x8C400001 Failed to establish database connection.
0x8C400005 Invalid flags value.
0x8C400007 The specified list has already been created.
0x8C40000D The list is designated as a Mailable list but does not contain an rcp_email column.
0x8C40000B The operation was canceled.
0x8C400003 Error while executing SQL/ADO operation.
0x8C40000E The list is designated as a User list but does not contain an rcp_guid column.
0x80040007 The ListManager object has not been properly initialized.

Remarks

This method has been rewritten for Commerce Server 2002 Service Pack 1 to increase accuracy. This change may result in decreased performance due to the rewriting of the method.

For a list of possible values for the lflags parameter, see the GetListFlags method.

[Visual Basic .NET]

Example

' oListID is an Object
oListID = oListManager.CreateFromSql("LegalTequillaBuyers", _
 "Tequilla buyers at least 21", 20, 0, "Provider=sqloledb;" & _
 "Data Source=TequillaServer;Initial Catalog=Margaritas;" & _
 "Integrated Security='SSPI'", "SELECT * FROM dbname.dbo.Tequilla " & _
 "WHERE Age >= 21", 10, 0)

Requirements

Namespace: Microsoft.CommerceServer.Interop.Targeting

Platforms: Windows 2000, Windows Server 2003

Assembly: listmanagerlib (in listmanagerlib.dll)

See Also

ListManager Class

Copyright © 2005 Microsoft Corporation.
All rights reserved.