This repository was archived by the owner on Feb 9, 2021. It is now read-only.
catdb
Folders and files
Name | Name | Last commit date | ||
---|---|---|---|---|
parent directory.. | ||||
<!--TO READ THIS HELP FILE, RIGHT-CLICK ON THE FILE NAME IN THE SOLUTION EXPLORER PANE AND SELECT "VIEW IN BROWSER"--> <html><head><title>CatDB Sample: Data Source Schema Browser</title></head><body><h1>CatDB Sample: Data Source Schema Browser</h1><div id="mainSection"><div id="mainBody"><div id="allHistory" class="saveHistory" onsave="saveAll()" onload="loadAll()"></div><p /><p>CatDB is ported from the MFC ODBC Catalog application. The application displays the schema information, such as tables and columns, of OLE DB providers. It is easy for you to track the differences between this sample and the MFC ODBC Catalog sample, because all of the changes from the MFC sample are surgical. This sample makes use of the <MSHelp:link keywords="25805F1B-26E3-402F-AF83-1B5FE5DDEBF7" tabindex="0" >CEnumerator</MSHelp:link>, <MSHelp:link keywords="99BF862C-9D5C-4117-9501-AA0E2672085C" tabindex="0" >CDataSource</MSHelp:link>, <MSHelp:link keywords="83CD798F-B45D-4F11-A23C-29183390450C" tabindex="0" >CSession</MSHelp:link>, and <MSHelp:link keywords="4BD881B3-26CA-4BDB-9226-D67560864F29" tabindex="0" >schema rowset classes</MSHelp:link>.</p><div class="alert"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Security Note </th></tr><tr><td><p>This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices.</p></td></tr></table></div><h1 class="heading">Building and Running the Sample</h1><div id="sectionSection0" class="seeAlsoNoToggleSection"><p>You can use this sample with the ODBC provider and with the Microsoft Access 97 and Microsoft SQL Server 6.5 databases (or later versions). To run this sample, you must have the MDAC SDK installed.</p><h4 class="subHeading">To build and run this sample</h4><div class="subSection"><ol><li><p>Open the solution file CatDB.sln.</p></li><li><p>From the <b>Build</b> menu, click <b>Build</b>.</p></li><li><p>From the <b>Debug</b> menu, click <b>Start Without Debugging</b>. </p><p>A dialog box will appear, titled "CatDB - [No data source selected]." </p></li><li><p>Click <b>Open</b> from the <b>File</b> menu. The <b>Data Link Properties</b> dialog box will appear. On the <b>Provider</b> tab, select Microsoft OLE DB Provider for SQL Server (or Microsoft Jet 4.0 OLE DB Provider). On the <b>Connection</b> tab, select the Northwind database. </p><p>The table information will appear in the dialog box's window. The dialog box title will change to the database name. </p></li></ol></div></div><h1 class="heading">How the Sample Works</h1><div id="sectionSection1" class="seeAlsoNoToggleSection"><p>The code to enumerate the providers, connect to a data source, and create a session is in the <code>CCatDBDoc::OnOpenDocument</code> function. The code to open the schema rowsets is in <code>CCatDBDoc::FetchTableInfo</code> and <code>CCatDBDoc::FetchColumnInfo</code>. Both <code>FetchTableInfo</code> and <code>FetchColumnInfo</code> use the OLE DB Templates schema rowset classes, <MSHelp:link keywords="57670F1B-BA99-43B0-B406-4C75B44F14F6" tabindex="0" >CTables</MSHelp:link> and <MSHelp:link keywords="7A4CA8E8-E041-4DEF-8C1A-00C211F7DA0B" tabindex="0" >CColumns</MSHelp:link>. The code to display the schema information is in <code>CCatDBView::OnUpdate</code>. The <code>OnUpdate </code>function moves through the records in the database and accesses the <b>CTables</b> and <b>CColumns</b> classes for data.</p><p>This sample demonstrates how to enumerate the OLE DB providers. <code>CEnumSourcesDlg</code> provides support to recursively display and connect to the data sources. The dialog box uses the OLE DB Templates <b>CEnumerator</b> class. To connect to the data source, <code>CEnumSourcesDlg</code> returns an <b>LPMONIKER</b> value for the selected data source. <b>CDataSource::Open</b> then takes this <b>LPMONIKER</b> value and performs the connection.</p><div class="alert"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Note </th></tr><tr><td><p>Some of the samples, such as this one, have not been modified to reflect the changes in the Visual C++ wizards, libraries, and compiler, but still demonstrate how to complete your desired task. </p></td></tr></table></div></div><h1 class="heading">Keywords</h1><div id="sectionSection2" class="seeAlsoNoToggleSection"><p>The sample demonstrates the following classes:</p><p>CColumns, CDataSource, CEnumerator, CSession, CTables</p><p>The sample demonstrates the following functions:</p><p>CDataSource::Open</p></div></div><div id="footer"><div class="footerLine"></div> © Microsoft Corporation. All rights reserved. Send <a href="mailto:DevDocs@microsoft.com?subject=Documentation Feedback :CatDB Sample: Data Source Schema Browser">comments</a> about this topic to Microsoft. </div></div></body></html>