The
following file is available for download from the Microsoft Download
Center:
Release Date:
9-29-2000
For additional information about how to download Microsoft
Support files, click the following article number to view the article in the
Microsoft Knowledge Base:
119591�
How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most
current virus-detection software that was available on the date that the file
was posted. The file is stored on security-enhanced servers that help to
prevent any unauthorized changes to the file.
The Oledbxpath.exe file contains the following files:
Collapse this tableExpand this table
File name | Size |
---|
EULA.txt | 2 KB |
CustomerOrder.xml | 2 KB |
OLEDBXPATH.cpp | 3 KB |
This samples demonstrates how to run an XPath query to
output an XML stream. The sample shows how to run an XPath query by using the
OLE DB
ICommandText interface. Alternatively, you can do this by using the
ICommandStreaminterface that contains an input stream which in turn contains the
XPath query.
Additionally, it provides a mapping schema file that
contains mapping information between elements and attributes in the XPath query
and the tables and columns contained in the back-end SQL Server 2000 relational
database management system (RDBMS). The CustomerOrder.xml mapping schema file
provided with this sample contains information regarding a SQL JOIN between the
Customers and Orders tables and their columns in terms of the Customers and
CustOrder elements and their attributes. The sample does the following:
- Sets the XPath query:
m_szCommand = "/Customers/CustOrder[@CustomerID=\"ALFKI\"]";
- Configures the Microsoft OLE DB Provider for SQL Server
(SQLOLEDB) property set DBPROPSET_SQLSERVERSTREAM, which is used for
configuring the input stream:
CDBPropSet propset(DBPROPSET_SQLSERVERSTREAM);
- Sets the Base Path property to the folder containing the mapping schema file:
propset.AddProperty(SSPROP_STREAM_BASEPATH, (LPCWSTR)m_path);
- Sets the Mapping Schema property to point to CustomerOrder.xml:
propset.AddProperty(SSPROP_STREAM_MAPPINGSCHEMA, OLESTR("CustomerOrder.xml"));
- Sets the dialect of ICommandText to DBGUID_XPATH:
if(FAILED(hr = m_spCommand->QueryInterface(&pCommandText)))
{
printf("Failed to get an ICommandStream interface...\n");
return hr;
}
if(FAILED(hr = pCommandText->SetCommandText(DBGUID_XPATH, T2COLE((LPCTSTR)m_szCommand))))
{
printf("Failed to set command stream.\n");
return hr;
}
- Runs the ICommand::Execute method and retrieves the XML data in an output ISequentialStream interface:
m_spCommand->Execute(NULL, IID_ISequentialStream, NULL, NULL, (IUnknown **) &pIXMLOutput );
Steps to Run the Sample
- Create an empty Win32 console application.
- On the General tab of the Project/Settings dialog box, change the Microsoft
Foundation Classes settings to Use MFC in a Static Library.
- Insert OLEDBXPath.cpp into the project.
- Copy CustomerOrder.xml into the project folder.
- Make sure that the project options point to the SQLOLEDB.H
file that ships with Microsoft Data Access Components (MDAC) 2.6
SDK.
- Modify the connection string to refer to a valid SQL Server
2000 database.
- Compile and then run the application.