共用方式為


CDataConnection::operator CDataSource&

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at CDataConnection::operator CDataSource&.

Returns a reference to the contained CDataSource object.

Syntax

  
operator const CDataSource&() throw( );  
  

Remarks

This operator returns a reference to the contained CDataSource object, allowing you to pass a CDataConnection object where a CDataSource reference is expected.

Example

If you have a function (such as func below) that takes a CDataSource reference, you can use CDataSource& to pass a CDataConnection object instead.

void SourceFunc(const CDataSource& theSource)
{
   CComVariant var;
   theSource.GetProperty(DBPROPSET_DATASOURCEINFO, DBPROP_DATASOURCENAME, &var);
}
   CDataConnection dc;
   dc.Open(szInit);
   SourceFunc(dc);

Requirements

Header: atldbcli.h

See Also

CDataConnection Class
CDataConnection::operator CDataSource*