COStream Class Overview

class COStream : virtual public CRtnInfo

        COStream simply wraps the functions of interfaces ISequentialStream and IGetSourceRow. Although it doesn't have a function to open a COStream object, a COStream object can be opened with one of three global template functions, BindObject<T>, CreateObject<T>, and Open<T>.

        Additionally, COStream has a function to retrieve a source row object which creates this stream object.

        For how to use it, see the example oledb25.

        Specifically, Microsoft OLE DB provider for SQL Sever 2000 supports a new dialect called DBGUID_MSSQLXML to execute XML templates with embedded queries. The following codes demonstrates how to open streams with XML queries with or without a parameter.

        LPOLESTR strXMLQuery=L"<ROOT xmlns:sql='urn:schemas-microsoft-com:xml-sql'> <sql:query>SELECT PRODUCTID, PRODUCTNAME FROM PRODUCTS WHERE PRODUCTNAME LIKE 'C%' FOR XML AUTO </sql:query> </ROOT>"; 

        LPOLESTR strXMLQueryWithParam=L"<ROOT xmlns:sql='urn:schemas-microsoft-com:xml-sql'> <sql:header><sql:param name='CategoryName'>Confections</sql:param></sql:header> <sql:query>select * from Categories where CategoryName = @CategoryName for XML AUTO</sql:query> </ROOT>";

        CBulkRecord<COStream>             XMLStream;
        CBulkRecordParam<COStream> XMLStreamParam;
        COSession                                       OSession;
        CODataSource                                ODataSource;
        CPInfoEx                                           PInfoEx;

        //error checks ignored
        ODataSource.Open();
        OSession.Open(ODataSource.m_pIDBInitialize);
        
        //open a stream using a XML query without a parameter
        if(XMLStream.OpenWithCmnd(OSession.m_pIOpenRowset, strXMLQuery, NULL, 1, DBGUID_MSSQLXML);){
        
        //Process XMLStream here

        }

        //set a CPInfoEx structure
        PInfoEx.m_nDBType=DBTYPE_WSTR;
        PInfoEx.m_pData=L"Condiments";
        PInfoEx.m_strPName=L"@CategoryName";

        //open a stream using a XML query with a parameter
        if(XMLStreamParam.Open(OSession.m_pIOpenRowset, strXMLQueryWithParam, &PInfoEx, NULL, 1, DBGUID_MSSQLXML, L'@')){

        //process XMLStreamParam

        }

COStream Class Members