Share via


DataSource Property

DataSource Property

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

The IDataSource interface on the object. This property is read-only.

Applies To

IFolder Interface

Type Library

Microsoft CDO for Exchange 2000 Library

DLL Implemented In

CDOEX.DLL

Syntax

[Visual Basic]Property DataSource As IDataSource

[C++]HRESULT get_DataSource(IDataSource** pVal);

Parameters

Remarks

This property returns the IDataSource interface on the object. Use the IDataSource interface exposed by the object to bind to items in an Exchange store or to other objects, such as Microsoft ActiveX Data Objects (ADO) Record or OLE DB Row objects. When binding to Record and Row objects, the underlying store item must be a container.

Examples

[Visual Basic]

' Reference to Microsoft ActiveX Data Objects 2.5 Library ' Reference to Microsoft CDO for Exchange 2000 Library

' Note: It is recommended that all input parameters be validated before being used. Function GetBoundFolder(Url As String) As CDO.Folder Set Fldr = New Folder Set GetBoundFolder = Fldr.DataSource.Open(Url, , _ adModeReadWrite, _ adFailIfNotExists)

End Function

' Note: It is recommended that all input parameters be validated before being used.

Function GetBoundFolder( Url ) Set Fldr = CreateObject("CDO.Folder") Set GetBoundFolder = Fldr.DataSource.Open(Url, , _ adModeReadWrite, _ adFailIfNotExists)

End Function

[C++]

/* You must have the following paths in your INCLUDE path. %CommonProgramFiles%\system\ado %CommonProgramFiles%\microsoft shared\cdo

*/ #ifndef _CORE_EXAMPLE_HEADERS_INCLUDED #define _CORE_EXAMPLE_HEADERS_INCLUDED #import <msado15.dll> no_namespace #import <cdoex.dll> no_namespace #include <iostream.h> #endif // Note: It is recommended that all input parameters be validated before being used. IFolderPtr CreateFolder(bstr_t url, bstr_t contentclass, bstr_t description) {

if(url == bstr_t("")) throw _com_error(E_POINTER);

_ConnectionPtr Conn(__uuidof(Connection)); IDataSourcePtr pDsrc(__uuidof(Folder));

Conn->Provider = "ExOLEDB.DataSource"; try { Conn->Open(url,bstr_t(),bstr_t(),-1); } catch(_com_error e) { throw e; }

IFolderPtr pFldr = pDsrc;

pFldr->ContentClass = contentclass; pFldr->Description = description;

try { pDsrc->SaveTo( url, variant_t((IDispatch*)Conn,true), adModeReadWrite, (RecordCreateOptionsEnum) ( adCreateCollection | adCreateOverwrite ), adOpenSource, bstr_t(), bstr_t()); } catch(_com_error e) { cerr << "Error saving folder to store" << endl; throw e; }

// close connection Conn->Close(); Conn = NULL;

return pFldr; }

Send us your feedback about the Microsoft Exchange Server 2003 SDK.

Build: June 2007 (2007.618.1)

© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.