Creates and binds to an object named by a URL and returns the requested interface pointer.
HRESULT CreateRow( IUnknown * pUnkOuter, LPCOLESTR pwszURL, DBBINDURLFLAG dwBindURLFlags, REFGUID rguid, REFIID riid, IAuthenticate * pAuthenticate, DBIMPLICITSESSION * pImplSession, DBBINDURLSTATUS * pdwBindStatus, LPOLESTR * ppwszNewURL, IUnknown ** ppUnk );
Parameters
Note Creating a row requires DBBINDURLFLAG_WRITE be set. This is independent of whether a row, rowset, or stream view of the resource is requested.
The flag values listed in the following table are also available on ICreateRow::CreateRow, in addition to the bind flags defined in IBindResource::Bind.
Flags | Meaning |
---|---|
DBBINDURLFLAG_COLLECTION | Creates the object as a collection. |
DBBINDURLFLAG_ISSTRUCTUREDDOCUMENT | Creates the object as a structured document. |
DBBINDURLFLAG_OPENIFEXISTS | If the resource exists and is not a collection, it is opened and S_OK is returned. If it exists and is a collection, DB_E_RESOURCEEXISTS is returned. If the resource does not exist, it is created.
This flag may not be used with DBBINDURLFLAG_OVERWRITE. Note All implementers of ICreateRow must support this flag. |
DBBINDURLFLAG_OVERWRITE | Deletes and re-creates a named object if it exists. This flag may not be used with DBBINDURLFLAG_OPENIFEXISTS. |
DBBINDURLFLAG_COLLECTION | DBBINDURLFLAG_OPENIFEXISTS | If the resource is not a collection, DB_E_NOTCOLLECTION is returned. If the resource exists and is a collection, it is opened and S_OK is returned. If the resource does not exist, it is created. |
Not all bind flags may be used with all object types (as specified in the rguid parameter). The following table describes the restrictions. If a client does not adhere to these restrictions, the bind will fail with E_INVALIDARG.
Object type | Restrictions |
---|---|
DBGUID_ROW | All flags are allowed.
DBBINDURLFLAG_OPENIFEXISTS and DBBINDURLFLAG_OVERWRITE may not be used together. |
DBGUID_ROWSET | DBBINDURLFLAG_COLLECTION must be specified.
DBBINDURLFLAG_OPENIFEXISTS and DBBINDURLFLAG_OVERWRITE may not be used together. In addition, the following flags are disallowed: DBBINDURLFLAG_DELAYFETCHCOLUMNS |
DBGUID_STREAM | DBBINDURLFLAG_OPENIFEXISTS and DBBINDURLFLAG_OVERWRITE may not be used together.
In addition, the following flags are disallowed: DBBINDURLFLAG_DELAYFETCHCOLUMNS |
DBGUID_ROW
DBGUID_ROWSET
DBGUID_STREAM
Note DBGUID_ROWSET can be requested only if the row represents a collection (that is, dwBindURLFlags set to DBBINDURLFLAG_COLLECTION).
Note ICreateRow::CreateRow uses pImplSession only when implemented on a binder object and binding to a row, rowset, or stream object (rguid is DBGUID_ROW, DBGUID_ROWSET, or DBGUID_STREAM). If implemented on any other object (for example, a session or row object), the provider ignores pImplSession because the existing object already has a session context.
Return Code
rguid was DBGUID_ROWSET, but the DBBINDURLFLAG_COLLECTION bit of dwBindURLFlags was not set.
pImplSession was not a null pointer, and pImplSession->piid was a null pointer.
dwBindURLFlags contained a flag labeled "Modifies DBBINDURLFLAG_*" in the dwBindURLFlags value table in the reference entry for IBindResource::Bind but did not contain the flag to be modified.
dwBindURLFlags contained both DBBINDURLFLAG_OPENIFEXISTS and DBBINDURLFLAG_OVERWRITE.
The provider does not support one or more values of dwBindURLFlags.
One of more of the bind flags in dwBindURLFlags are either not supported by the provider or disallowed for the object type denoted by rguid. For flags allowed for each object type, see the table in the reference entry for IBindResource::Bind.
DB_S_ASYNCHRONOUS should be returned before DB_S_ERRORSOCCURRED.
DB_S_ASYNCHRONOUS should be returned before DB_S_ERRORSOCCURRED. Once rowset population is complete, the consumer can see DB_S_ERRORSOCCURRED either by calling IDBAsynchStatus::GetStatus or by receiving IDBAsynchNotify::OnStop.
pUnkOuter was not a null pointer, and riid was not IID_IUnknown.
pImplSession was not a null pointer, pImplSession->pUnkOuter was not a null pointer, and pImplSession->piid did not point to IID_IUnknown.
pImplSession was not a null pointer, pImplSession->pUnkOuter was not a null pointer, and the object being created does not support aggregation.
The provider does not allow the creation of resources via ICreateRow.
Comments
ICreateRow::CreateRow provides the ability to create a new object named by a URL and bind it directly to a row, to a rowset, or to a row and a default stream object. If a consumer calls CreateRow on a URL that does not exist and rguid is set to DBGUID_STREAM, both a row and a default stream object are created. Only the stream object may be aggregated. The provider returns the requested interface pointer on the stream object.
The created row object "inherits" the default columns of its container's class. The provider determines what these default columns are. Whether or not to allow creation of a root row object with no inherited columns is provider-specific. For "document source" providers (that is, providers for which the value of DBPROP_DATASOURCE_TYPE is DBPROPVAL_DST_DOCSOURCE), the default columns are the columns of the resource rowset. For example, a new document inherits the default columns of its folder's class, which are the columns of the resource rowset.
Columns may be added by calling IRowSchemaChange::AddColumns. Column values may also be set with IRowChange::SetColumns.
The provider determines what the container, or parent row, is for its hierarchy. Atomic rows (for example, simple documents) are leaf nodes in a hierarchy. Collections are root nodes or intermediate nodes in a hierarchy. For example, a document's container is a folder. Given a row object, a consumer can obtain the parent by obtaining the parent URL and binding to it.
The DBBINDURLFLAG_OPENIFEXISTS and DBBINDURLFLAG_OVERWRITE bind flags may be used to specify behavior when the URL denotes an existing row. If a consumer calls ICreateRow::CreateRow on a URL that exists and does not specify DBBINDURLFLAG_OPENIFEXISTS or DBBINDURLFLAG_OVERWRITE, the provider must return DB_E_RESOURCEEXISTS. The result does not depend on the value of rguid. (The value of rguid could be DBGUID_ROW or DBGUID_STREAM.) Providers are not required to support these flags. If these flags are not supported and the consumer uses them to open a resource, the provider returns DB_E_RESOURCEEXISTS (the same error that is returned if the flag is not specified). These flags are disallowed on IBindResource::Bind. The following table outlines the behavior with and without these two flags.
Method, bind flag | Row exists | Row does not exist |
---|---|---|
Bind | Open | Fail |
CreateRow | Fail | Create |
CreateRow, DBBINDURLFLAG_OPENIFEXISTS |
Open | Create |
CreateRow, DBBINDURLFLAG_OVERWRITE |
Create | Create |
If the object was created and no warnings are issued, the provider returns S_OK. If the object was created with warnings, the provider returns DB_S_ERRORSOCCURRED. *pdwBindStatus contains any warning flags.
Binding semantics, except where noted, are identical to those of IBindResource::Bind. See the reference entry for IBindResource::Bind for a full discussion of bind flags and additional binding properties.
The scope of the session object associated with the object obtained in this call to ICreateRow::CreateRow is defined by the URL that was requested in the bind call. For more information, see "Direct Binding" in Chapter 8: Binder Objects and Direct Binding, as well as the "Comments" section of the reference entry for IBindResource::Bind.
Note "Provider Binder Objects" in Chapter 8 discusses case-sensitivity issues for URL-to-provider mapping.
Row creation and binding operations can be performed asynchronously. For more information on asynchronous processing in OLE DB, see Chapter 17: Asynchronous Processing.
The consumer may also support and register the IAuthenticate interface via pAuthenticate to provide information to authenticate the user. If the client registers an IAuthenticate pointer, it will be called if access to the requested resource is denied. The initial attempt to access the resource uses anonymous credentials or the default logged-in credentials. For more information, see IAuthenticate in the MSDN Library documentation.
The caller should convert noncanonical URLs to canonical form before invoking this method. Providers must return URLs in canonical form. For more information, see the Win32® Internet API function InternetCanonicalizeUrl in the Site Builder Network (SBN) Workshop documentation at http://msdn.microsoft.com/workshop/networking/default.asp.
If returning a result code that indicates success, the provider must return it in the following order of precedence:
Providers may own the responsibility for determining the suffix portion of the new URL. If DBPROP_GENERATEURL is DBPROPVAL_GU_SUFFIX, the caller specifies the path of the new URL in *pwszURL. The provider generates the URL suffix and returns the entire URL in **ppwszNewURL.