Skip to content
This repository was archived by the owner on Feb 9, 2021. It is now read-only.

Latest commit

 

History

History

DynamicConsumer

<!--TO READ THIS HELP FILE, RIGHT-CLICK ON THE FILE NAME IN THE
    SOLUTION EXPLORER PANE AND SELECT "VIEW IN BROWSER"-->

<html><head><title>DynamicConsumer Sample: Uses Dynamic Accessor and Schema Rowset Classes to Read Metadata from a Database</title></head><body><h1>DynamicConsumer Sample: Uses Dynamic Accessor and Schema Rowset Classes to Read Metadata from a Database</h1><div id="mainSection"><div id="mainBody"><div id="allHistory" class="saveHistory" onsave="saveAll()" onload="loadAll()"></div><p /><p>The DynamicConsumer sample is a simple console application that allows you to connect to any data source and select a table or stored procedure. If you select a stored procedure, the sample application will prompt you to enter the values for parameters. It then executes a command to display the data in the result rowset.</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"><h4 class="subHeading">To build and run this sample</h4><div class="subSection"><ol><li><p>Open the solution file DynamicConsumer.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></li><li><p>A console window will appear, prompting you to specify which kind of accessor to use. Enter a number to specify an accessor type. Other specification menus will follow, depending on your choice.</p></li><li><p>When you are finished with the menu selections, the <b>Data Link Properties</b> dialog box will appear. On the <b>Provider</b> tab, select Microsoft OLE DB Provider for SQL Server. On the <b>Connection</b> tab, select a database such as Northwind.</p></li><li><p>When you have selected a data source, the console prompts you to specify the table from which you want to print out data. When you do so, the table's data displays in the console.</p></li></ol></div></div><h1 class="heading">How the Sample Works</h1><div id="sectionSection1" class="seeAlsoNoToggleSection"><p>The sample uses schema rowset classes to read metadata from the data source. Metadata is any information about a data source other than the data stored in the database, such as column names, column data types, table names, or stored procedures. DynamicConsumer uses the schema rowset classes <b>CTables</b>, <b>CProcedures</b>, and <b>CProcedureParameters</b> to select the table or procedure and to build a SQL command string dynamically. The sample also uses the following accessor classes:  </p><ul><li><p><b>CDynamicAccessor</b> (demonstrates the various ways to handle BLOB data)</p></li><li><p><b>CDynamicStringAccessor</b></p></li><li><p><b>CXMLAccessor</b></p></li><li><p><b>CDynamicParameterAccessor</b></p></li></ul></div><h1 class="heading">Keywords</h1><div id="sectionSection2" class="seeAlsoNoToggleSection"><p>The sample demonstrates the following classes:</p><p>CDynamicAccessor, CDynamicParameterAccessor, CDynamicStringAccessor, CProcedureParameters, CProcedures, CTables, CXMLAccessor</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 :DynamicConsumer Sample: Uses Dynamic Accessor and Schema Rowset Classes to Read Metadata from a Database">comments</a> about this topic to Microsoft.
      </div></div></body></html>