Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DynamicConsumer Sample: Uses Dynamic Accessor and Schema Rowset Classes to Read Metadata from a Database

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.

Security noteSecurity Note:

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. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.

To get samples and instructions for installing them:

  • On the Visual Studio Help menu, click Samples.

    For more information, see Visual Studio Samples.

  • The most recent version and complete list of samples is available online from the Visual Studio 2008 Samples page.

  • You can also locate samples on your computer's hard disk. By default, samples and a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. For Express editions of Visual Studio, all samples are located online.

To build and run this sample

  1. Open the solution file DynamicConsumer.sln.

  2. From the Build menu, click Build.

  3. From the Debug menu, click Start Without Debugging.

  4. 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.

  5. When you are finished with the menu selections, the Data Link Properties dialog box will appear. On the Provider tab, select Microsoft OLE DB Provider for SQL Server. On the Connection tab, select a database such as Northwind.

  6. 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.

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 CTables, CProcedures, and CProcedureParameters to select the table or procedure and to build a SQL command string dynamically. The sample also uses the following accessor classes:

  • CDynamicAccessor (demonstrates the various ways to handle BLOB data)

  • CDynamicStringAccessor

  • CXMLAccessor

  • CDynamicParameterAccessor

The sample demonstrates the following classes:

CDynamicAccessor, CDynamicParameterAccessor, CDynamicStringAccessor, CProcedureParameters, CProcedures, CTables, CXMLAccessor

Other Resources

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2015 Microsoft