Skip to content

Commit 98d860b

Browse files
Matthew SeboltColin Robertson
authored andcommitted
oledb-tutorial-review pr3 (MicrosoftDocs#1476)
* oledb-tutorial-review pr3 * broken link * minor edit * minor edit * minor formats * changes per @corob-msft * link updates * Update creating-an-ole-db-provider.md - Updated links to samples.
1 parent 35f1f33 commit 98d860b

7 files changed

+38
-35
lines changed

docs/data/oledb/consumer-wizard-generated-classes.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Consumer Wizard-Generated Classes | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "11/04/2016"
4+
ms.date: "10/15/2018"
55
ms.technology: ["cpp-data"]
66
ms.topic: "reference"
77
dev_langs: ["C++"]
@@ -13,13 +13,13 @@ ms.workload: ["cplusplus", "data-storage"]
1313
---
1414
# Consumer Wizard-Generated Classes
1515

16-
When you use the ATL OLE DB Consumer Wizard to generate a consumer, you have the choice of using OLE DB Templates or OLE DB attributes. In both cases, the wizard generates a command class and a user record class. The command class contains code to open the data source and rowset you specified in the wizard. The user record class contains a column map for the database table you selected. However, the generated code differs in each case:
16+
When you use the **ATL OLE DB Consumer Wizard** to generate a consumer, you have the choice of using OLE DB Templates or OLE DB attributes. In both cases, the wizard generates a command class and a user record class. The command class contains code to open the data source and rowset you specified in the wizard. The user record class contains a column map for the database table you selected. However, the generated code differs in each case:
1717

18-
- If you select a templated consumer, the wizard generates a command class and a user record class. The command class will have the name that you enter in the Class box in the wizard (for example, `CProducts`), and the user record class will have a name of the form "*ClassName*Accessor" (for example, `CProductsAccessor`). Both classes are placed in the consumer's header file.
18+
- If you select a templated consumer, the wizard generates a command class and a user record class. The command class will have the name that you enter in the **Class** box in the wizard (for example, `CProducts`), and the user record class will have a name of the form "*ClassName*Accessor" (for example, `CProductsAccessor`). Both classes are placed in the consumer's header file.
1919

2020
- If you select an attributed consumer, the user record class will have a name of the form "_*ClassName*Accessor" and will be injected. That is, you will be able to view only the command class in the text editor; you can only view the user record class as injected code. For information about viewing injected code, see [Debugging Injected Code](/visualstudio/debugger/how-to-debug-injected-code).
2121

22-
The following examples use a command class created on the Products table of the Northwind database to demonstrate the wizard-generated consumer code for the command class and user record class.
22+
The following examples use a command class created on the `Products` table of the `Northwind` database to demonstrate the wizard-generated consumer code for the command class and user record class.
2323

2424
## Templated User Record Classes
2525

@@ -30,10 +30,10 @@ If you create an OLE DB consumer using the OLE DB Templates (rather than the OLE
3030
The first part of the user record class includes the data member declarations and the status and length data members for each data-bound column. For information about these data members, see [Field Status Data Members in Wizard-Generated Accessors](../../data/oledb/field-status-data-members-in-wizard-generated-accessors.md).
3131

3232
> [!NOTE]
33-
> If you modify the user record class or write your own consumer, the data variables must come before the status and length variables.
33+
> If you modify the user record class or write your own consumer, the data variables must come before the status and length variables.
3434
3535
> [!NOTE]
36-
> The ATL OLE DB Consumer Wizard uses the `DB_NUMERIC` type to bind numeric data types. It formerly used `DBTYPE_VARNUMERIC` (the format of which is described by the `DB_VARNUMERIC` type; see Oledb.h). If you do not use the wizard to create consumers, it is recommended that you use `DB_NUMERIC`.
36+
> The ATL OLE DB Consumer Wizard uses the `DB_NUMERIC` type to bind numeric data types. It formerly used `DBTYPE_VARNUMERIC` (the format of which is described by the `DB_VARNUMERIC` type; see Oledb.h). If you do not use the wizard to create consumers, it is recommended that you use `DB_NUMERIC`.
3737
3838
```cpp
3939
// Products.H : Declaration of the CProducts class
@@ -142,7 +142,7 @@ class CProducts : public CCommand<CAccessor<CProductsAccessor>>
142142

143143
## Attribute-Injected User Record Classes
144144

145-
If you create an OLE DB consumer using the database attributes ([db_command](../../windows/db-command.md) or [db_table](../../windows/db-table.md)), the attributes inject a user record class with a name of the form "_*ClassName*Accessor." For example, if you named your command class `COrders`, the user record class will be `_COrdersAccessor`. Although the user record class appears in Class View, double-clicking it navigates to the command or table class in the header file instead. In these cases, you can only view the actual declaration of the user record class by viewing the attribute-injected code.
145+
If you create an OLE DB consumer using the database attributes ([db_command](../../windows/db-command.md) or [db_table](../../windows/db-table.md)), the attributes inject a user record class with a name of the form "_*ClassName*Accessor." For example, if you named your command class `COrders`, the user record class will be `_COrdersAccessor`. Although the user record class appears in **Class View**, double-clicking it navigates to the command or table class in the header file instead. In these cases, you can only view the actual declaration of the user record class by viewing the attribute-injected code.
146146

147147
There can be potential complications if you add or override methods in attributed consumers. For example, you could add a `_COrdersAccessor` constructor to the `COrders` declaration, but note that in reality this adds a constructor to the injected `COrdersAccessor` class. Such a constructor can initialize the columns/parameters, but you cannot create a copy constructor this way, because it cannot directly instantiate the `COrdersAccessor` object. If you need a constructor (or other method) directly on the `COrders` class, it is recommended that you define a new class deriving from `COrders` and add the necessary methods there.
148148

docs/data/oledb/creating-a-consumer-without-using-a-wizard.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Creating a Consumer Without Using a Wizard | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "11/04/2016"
4+
ms.date: "10/12/2018"
55
ms.technology: ["cpp-data"]
66
ms.topic: "reference"
77
dev_langs: ["C++"]
@@ -17,7 +17,7 @@ The following example assumes that you are adding OLE DB consumer support to an
1717

1818
To add OLE DB consumer support without using the ATL OLE DB Consumer Wizard:
1919

20-
- In your Stdafx.h file, append the following `#include` statements:
20+
- In your pch.h file, append the following `#include` statements:
2121

2222
```cpp
2323
#include <atlbase.h>
@@ -27,10 +27,10 @@ To add OLE DB consumer support without using the ATL OLE DB Consumer Wizard:
2727

2828
Programmatically, a consumer typically performs the following sequence of operations:
2929

30-
- Create a user record class that binds columns to local variables. In this example, `CMyTableNameAccessor` is the user record class (see [User Records](../../data/oledb/user-records.md)). This class contains the column map and parameter map. Declare a data member in the user record class for each field you specify in your column map; for each of these data members, also declare a status data member and a length data member. For more information, see [Field Status Data Members in Wizard-Generated Accessors](../../data/oledb/field-status-data-members-in-wizard-generated-accessors.md).
30+
1. Create a user record class that binds columns to local variables. In this example, `CMyTableNameAccessor` is the user record class (see [User Records](../../data/oledb/user-records.md)). This class contains the column map and parameter map. Declare a data member in the user record class for each field you specify in your column map; for each of these data members, also declare a status data member and a length data member. For more information, see [Field Status Data Members in Wizard-Generated Accessors](../../data/oledb/field-status-data-members-in-wizard-generated-accessors.md).
3131

3232
> [!NOTE]
33-
> If you write your own consumer, the data variables must come before the status and length variables.
33+
> If you write your own consumer, the data variables must come before the status and length variables.
3434

3535
- Instantiate a data source and a session. Decide what type of accessor and rowset to use and then instantiate a rowset using [CCommand](../../data/oledb/ccommand-class.md) or [CTable](../../data/oledb/ctable-class.md):
3636

@@ -56,7 +56,7 @@ Programmatically, a consumer typically performs the following sequence of operat
5656
hr = rs.Open(); // (Open also executes the command)
5757
```
5858

59-
- Optionally, set rowset properties using `CDBPropSet::AddProperty` and pass them as a parameter to `rs.Open`. For an example of how this is done, see GetRowsetProperties in [Consumer Wizard-Generated Methods](../../data/oledb/consumer-wizard-generated-methods.md).
59+
- Optionally, set rowset properties using `CDBPropSet::AddProperty` and pass them as a parameter to `rs.Open`. For an example of how this is done, see **GetRowsetProperties** in [Consumer Wizard-Generated Methods](../../data/oledb/consumer-wizard-generated-methods.md).
6060

6161
- You can now use the rowset to retrieve/manipulate the data.
6262

@@ -72,7 +72,7 @@ Programmatically, a consumer typically performs the following sequence of operat
7272

7373
- Call `CoUnInitialize` to uninitialize COM. This is usually called in the main code.
7474

75-
```
75+
```cpp
7676
CoUninitialize();
7777
```
7878

docs/data/oledb/creating-a-project-for-the-provider.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ ms.workload: ["cplusplus", "data-storage"]
1313
---
1414
# Creating a Project for the Provider
1515

16-
### To create a project in which the OLE DB provider will reside
16+
## To create a project in which the OLE DB provider will reside
1717

1818
1. From the **File** menu, click **New**, and then click **Project**.
1919

2020
The **New Project** dialog box appears.
2121

22-
1. In the Project Types pane, click the Visual C++ Projects folder. In the Templates pane, click **ATL Project**.
22+
1. In the **Project Types** pane, click the **Visual C++ Projects** folder. In the **Templates** pane, click **ATL Project**.
2323

2424
1. In the **Name** box, enter a name for the project, and then click **OK**.
2525

26-
The ATL Project Wizard appears.
26+
The **ATL Project Wizard** appears.
2727

28-
1. In the ATL Project Wizard, choose **Dynamic-Link Library (DLL)** for **Server Type**.
28+
1. In the **ATL Project Wizard**, choose **Dynamic-Link Library (DLL)** for **Application Type**.
2929

3030
1. Click **Finish**.
3131

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Creating an OLE DB Provider | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "11/04/2016"
4+
ms.date: "10/13/2018"
55
ms.technology: ["cpp-data"]
66
ms.topic: "reference"
77
dev_langs: ["C++"]
@@ -16,23 +16,26 @@ ms.workload: ["cplusplus", "data-storage"]
1616
The recommended way to create an OLE DB provider is to use the wizards to create an ATL COM project and a provider and then modify the files using the OLE DB templates. As you customize your provider, you can comment out unwanted properties and add optional interfaces.
1717

1818
The basic steps are as follows:
19+
20+
1. Use the **ATL Project Wizard** to create the basic project files and the **ATL OLEDB Provider Wizard** to create the provider (select **ATL OLEDB Provider** from the **Installed** > **Visual C++** > **ATL** folder in **Add New Item**).
21+
22+
> [!NOTE]
23+
> The project must include MFC support before adding a **ATL OLEDB Provider**.
1924
20-
1. Use the ATL Project Wizard to create the basic project files and the ATL OLE DB Provider Wizard to create the provider (select **ATL OLE DB Provider** from the Visual C++ folder in **Add Class**).
21-
22-
1. Modify the code in the `Execute` method in CMyProviderRS.h. For an example, see [Reading Strings Into an OLE DB Provider](../../data/oledb/reading-strings-into-the-ole-db-provider.md).
25+
1. Modify the code in the `Execute` method in [CMyProviderRowset(MyProviderRS.h)](cmyproviderrowset-myproviderrs-h.md). For an example, see [Reading Strings Into an OLE DB Provider](../../data/oledb/reading-strings-into-the-ole-db-provider.md).
2326

24-
1. Edit the property maps in MyProviderDS.h, MyProviderSess.h, and MyProviderRS.h. The wizard creates property maps that contain all properties that a provider might implement. Go through the property maps and remove or comment out properties that your provider does not need to support.
27+
1. Edit the property maps in [MyProviderDS.h](cmyprovidersource-myproviderds-h.md), [MyProviderSess.h](cmyprovidersession-myprovidersess-h.md), and [MyProviderRS.h](cmyproviderrowset-myproviderrs-h.md). The wizard creates property maps that contain all properties that a provider might implement. Go through the property maps and remove or comment out properties that your provider does not need to support.
2528

26-
1. Update the PROVIDER_COLUMN_MAP, which can be found in MyProviderRS.h. For an example, see [Storing Strings In the OLE DB Provider](../../data/oledb/storing-strings-in-the-ole-db-provider.md).
29+
1. Update the PROVIDER_COLUMN_MAP, which can be found in [CMyProviderRowset(MyProviderRS.h)](cmyproviderrowset-myproviderrs-h.md). For an example, see [Storing Strings In the OLE DB Provider](../../data/oledb/storing-strings-in-the-ole-db-provider.md).
2730

28-
1. When you are ready to test your provider, you can test it by trying to find the provider in a provider enumeration. For examples of test code that finds a provider in an enumeration, see the [CATDB](https://github.com/Microsoft/VCSamples) and [DBVIEWER](https://github.com/Microsoft/VCSamples) samples or the example in [Implementing A Simple Consumer](../../data/oledb/implementing-a-simple-consumer.md).
31+
1. When you are ready to test your provider, you can test it by trying to find the provider in a provider enumeration. For examples of test code that finds a provider in an enumeration, see the [CATDB](https://github.com/Microsoft/VCSamples/tree/master/VC2008Samples/ATL/OLEDB/Consumer/catdb) and [DBVIEWER](https://github.com/Microsoft/VCSamples/tree/master/VC2008Samples/ATL/OLEDB/Consumer/dbviewer) samples or the example in [Implementing A Simple Consumer](../../data/oledb/implementing-a-simple-consumer.md).
2932

3033
1. Add any additional interfaces you want. For an example, see [Enhancing the Simple Read-Only Provider](../../data/oledb/enhancing-the-simple-read-only-provider.md).
3134

32-
> [!NOTE]
33-
> By default, the wizards generate code that is OLE DB level 0 compliant. To ensure that your application remains level 0 compliant, do not remove any of the wizard-generated interfaces from the code.
35+
> [!NOTE]
36+
> By default, the wizards generate code that is OLE DB level 0 compliant. To ensure that your application remains level 0 compliant, do not remove any of the wizard-generated interfaces from the code.
3437
3538
## See Also
3639

37-
[CATDB](https://github.com/Microsoft/VCSamples)<br/>
38-
[DBVIEWER](https://github.com/Microsoft/VCSamples)
40+
[CatDB Sample: Data Source Schema Browser](https://github.com/Microsoft/VCSamples/tree/master/VC2008Samples/ATL/OLEDB/Consumer/catdb)<br/>
41+
[DBViewer Sample: Database Browser](https://github.com/Microsoft/VCSamples/tree/master/VC2008Samples/ATL/OLEDB/Consumer/dbviewer)

docs/data/oledb/creating-the-provider.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Creating the Provider | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "11/04/2016"
4+
ms.date: "10/15/2018"
55
ms.technology: ["cpp-data"]
66
ms.topic: "reference"
77
dev_langs: ["C++"]
@@ -13,23 +13,23 @@ ms.workload: ["cplusplus", "data-storage"]
1313
---
1414
# Creating the Provider
1515

16-
#### To create an OLE DB provider with the ATL OLE DB Provider Wizard
16+
## To create an OLE DB provider with the ATL OLE DB Provider Wizard
1717

1818
1. Right-click the project.
1919

2020
1. On the shortcut menu, click **Add**, and then click **Add Class**.
2121

22-
1. In the **Add Class** dialog box, select the **ATL OLE DB Provider** icon, and then click **Open**.
22+
1. In the **Add Class** dialog box, under **Installed** > **Visual C++** > **ATL**, select the **ATL OLEDB Provider** icon, and then click **Open**.
2323

24-
1. In the ATL OLE DB Provider Wizard, enter a short name for your provider in the **Short Name** box. The following topics use the short name "MyProvider", but you can use another name. The other name boxes populate according to the name you enter.
24+
1. In the **ATL OLE DB Provider Wizard**, enter a short name for your provider in the **Short Name** box. The following topics use the short name "MyProvider", but you can use another name. The other name boxes populate according to the name you enter.
2525

2626
1. Edit the other name boxes, if needed. In addition to the object and file names, you can edit the following:
2727

2828
- **Coclass**: The name that COM uses to create the provider.
2929

3030
- **ProgID**: The programmatic identifier, which is a text string that can be used instead of a GUID.
3131

32-
- **Version**: Used with the ProgID and coclass to generate a version-dependent programmatic ID.
32+
- **Version**: Used with the ProgID and Coclass to generate a version-dependent programmatic ID.
3333

3434
1. Click **Finish**.
3535

docs/data/oledb/ole-db-programming.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ In addition, you can use attributes to implement the OLE DB consumer templates.
2727
|Using the OLE DB provider templates (conceptual topics)|[OLE DB Provider Templates](../../data/oledb/ole-db-provider-templates-cpp.md)|
2828
|OLE DB templates classes and macros|[OLE DB Templates Reference](../../data/oledb/ole-db-templates.md) (Visual C++)|
2929
|OLE DB consumer attributes|[OLE DB Consumer Attributes](../../windows/ole-db-consumer-attributes.md)|
30-
|OLE DB interfaces|[OLE DB programmer's reference](/previous-versions/windows/desktop/ms713643) (in the Windows SDK)|
30+
|OLE DB interfaces|[OLE DB programmer's reference](/previous-versions/windows/desktop/ms713643(v%3dvs.85)) (in the Windows SDK)|
3131
|OLE DB templates samples|[OLE DB Templates Samples](https://github.com/Microsoft/VCSamples)|
3232
|Data access programming overview (Visual C++)|[Data Access Programming](../../data/data-access-programming-mfc-atl.md)|
3333
|ODBC conceptual topics|[Open Database Connectivity (ODBC)](../../data/odbc/open-database-connectivity-odbc.md)|

docs/data/oledb/reading-strings-into-the-ole-db-provider.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Reading Strings into the OLE DB Provider | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "11/04/2016"
4+
ms.date: "10/13/2018"
55
ms.technology: ["cpp-data"]
66
ms.topic: "reference"
77
dev_langs: ["C++"]

0 commit comments

Comments
 (0)