Skip to content

Commit 4b5ea95

Browse files
authored
Merge pull request MicrosoftDocs#1500 from msebolt/oledb-tutorial-review-pr6
oledb tutorial review pr6
2 parents 6cdcb36 + 97f4bb1 commit 4b5ea95

27 files changed

Lines changed: 101 additions & 108 deletions

docs/data/oledb/accessors-and-rowsets.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Accessors and Rowsets | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "11/04/2016"
4+
ms.date: "10/22/2018"
55
ms.technology: ["cpp-data"]
66
ms.topic: "reference"
77
dev_langs: ["C++"]
@@ -26,7 +26,7 @@ Accessor Classes
2626

2727
- [CAccessor](../../data/oledb/caccessor-class.md) Use this accessor when you know the structure of the database source at design time. `CAccessor` statically binds a database record, which contains the buffer, to the data source.
2828

29-
- [CDynamicAccessor](../../data/oledb/cdynamicaccessor-class.md) Use this accessor when you do not know the structure of the database at design time. `CDynamicAccessor` calls `IColumnsInfo::GetColumnInfo` to get the database column information. It creates and manages an accessor and the buffer.
29+
- [CDynamicAccessor](../../data/oledb/cdynamicaccessor-class.md) Use this accessor when you don't know the structure of the database at design time. `CDynamicAccessor` calls `IColumnsInfo::GetColumnInfo` to get the database column information. It creates and manages an accessor and the buffer.
3030

3131
- [CDynamicParameterAccessor](../../data/oledb/cdynamicparameteraccessor-class.md) Use this accessor to handle unknown command types. When you prepare the commands, `CDynamicParameterAccessor` can get parameter information from the `ICommandWithParameters` interface, if the provider supports `ICommandWithParameters`.
3232

@@ -53,7 +53,7 @@ The following figure shows the rowset types.
5353
![RowsetType graphic](../../data/oledb/media/vcrowsettypes.gif "vcrowsettypes")
5454
Rowset Classes
5555

56-
[Schema rowsets](../../data/oledb/obtaining-metadata-with-schema-rowsets.md) do not access data in the data store but instead access information about the data store, called metadata. Schema rowsets are typically used in situations in which the database structure is not known at compile time and must be obtained at run time.
56+
[Schema rowsets](../../data/oledb/obtaining-metadata-with-schema-rowsets.md) don't access data in the data store but instead access information about the data store, called metadata. Schema rowsets are typically used in situations in which the database structure isn't known at compile time and must be obtained at run time.
5757

5858
## See Also
5959

docs/data/oledb/commands-and-tables.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Commands and Tables | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "11/04/2016"
4+
ms.date: "10/22/2018"
55
ms.technology: ["cpp-data"]
66
ms.topic: "reference"
77
dev_langs: ["C++"]
@@ -18,7 +18,7 @@ Commands and tables allow you to access rowsets; that is, open rowsets, execute
1818
![CCommand and CTable](../../data/oledb/media/vccommandstables.gif "vccommandstables")
1919
Command and Table Classes
2020

21-
In the previous table, `TAccessor` can be any accessor type listed in [Accessor Types](../../data/oledb/accessors-and-rowsets.md). *TRowset* can be any rowset type listed in [Rowset Types](../../data/oledb/accessors-and-rowsets.md). *TMultiple* specifies the result type (a single or multiple result set).
21+
In the previous table, `TAccessor` can be any accessor type listed in [Accessor Types](../../data/oledb/accessors-and-rowsets.md). `TRowset` can be any rowset type listed in [Rowset Types](../../data/oledb/accessors-and-rowsets.md). `TMultiple` specifies the result type (a single or multiple result set).
2222

2323
The [ATL OLE DB Consumer Wizard](../../atl/reference/atl-ole-db-consumer-wizard.md) lets you specify whether you want a command or table object.
2424

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Creating a Project for the Provider | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "11/04/2016"
4+
ms.date: "10/22/2018"
55
ms.technology: ["cpp-data"]
66
ms.topic: "reference"
77
dev_langs: ["C++"]
@@ -19,7 +19,10 @@ ms.workload: ["cplusplus", "data-storage"]
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 **Installed** > **Visual C++** > **MFC/ATL** folder. In the **Templates** pane, click **ATL Project**.
23+
24+
> [!NOTE]
25+
> In previous versions of Visual Studio, find the project type under **Installed** > **Templates** > **Visual C++** > **ATL**.
2326
2427
1. In the **Name** box, enter a name for the project, and then click **OK**.
2528

docs/data/oledb/creating-an-ole-db-consumer-using-a-wizard.md

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

16-
This procedure demonstrates how you can use the ATL Project Wizard and ATL OLE DB Consumer Wizard to generate an OLE DB Templates consumer and then modify the main code of the console application to retrieve and display data from a database table.
16+
This procedure demonstrates how you can use the **ATL Project Wizard** and **ATL OLE DB Consumer Wizard* to generate an OLE DB Templates consumer and then modify the main code of the console application to retrieve and display data from a database table.
1717

1818
The last two sections explain the wizard-generated OLE DB consumer code.
1919

docs/data/oledb/creating-an-ole-db-consumer.md

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

16-
You can create an OLE DB Templates consumer with or without the ATL OLE DB Consumer Wizard, though using the wizard is the recommended method. A consumer can operate in any application that supports ATL.
16+
You can create an OLE DB Templates consumer with or without the **ATL OLE DB Consumer Wizard**, though using the wizard is the recommended method. A consumer can operate in any application that supports ATL.
1717

1818
This section covers the following topics:
1919

docs/data/oledb/creating-an-updatable-provider.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This topic assumes that you are starting with a workable provider. There are two
2020
Next, you must make sure your provider contains all the functionality to support anything the consumer might request of it. If the consumer wants to update the data store, the provider has to contain code that persists data to the data store. For example, you might use the C Run-Time Library or MFC to perform such operations on your data source. The section "[Writing to the Data Source](#vchowwritingtothedatasource)" describes how to write to the data source, deal with NULL and default values, and set column flags.
2121

2222
> [!NOTE]
23-
> [UpdatePV](https://github.com/Microsoft/VCSamples/tree/master/VC2010Samples/ATL/OLEDB/Provider/UPDATEPV) is an example of an updatable provider. UpdatePV is the same as MyProv but with updatable support.
23+
> [UpdatePV](https://github.com/Microsoft/VCSamples/tree/master/VC2010Samples/ATL/OLEDB/Provider/UPDATEPV) is an example of an updatable provider. UpdatePV is the same as MyProv but with updatable support.
2424
2525
## <a name="vchowmakingprovidersupdatable"></a> Making Providers Updatable
2626

@@ -34,7 +34,7 @@ You must first decide whether to inherit from `IRowsetChangeImpl` or `IRowsetUpd
3434

3535
Note that `IRowsetUpdateImpl` derives from `IRowsetChangeImpl`. Thus, `IRowsetUpdateImpl` gives you change capability plus batch capability.
3636

37-
#### To support updatability in your provider
37+
### To support updatability in your provider
3838

3939
1. In your rowset class, inherit from `IRowsetChangeImpl` or `IRowsetUpdateImpl`. These classes provide appropriate interfaces for changing the data store:
4040

@@ -57,7 +57,7 @@ Note that `IRowsetUpdateImpl` derives from `IRowsetChangeImpl`. Thus, `IRowsetUp
5757
```
5858

5959
> [!NOTE]
60-
> You should remove the `IRowsetChangeImpl` line from your inheritance chain. This one exception to the directive previously mentioned must include the code for `IRowsetChangeImpl`.
60+
> You should remove the `IRowsetChangeImpl` line from your inheritance chain. This one exception to the directive previously mentioned must include the code for `IRowsetChangeImpl`.
6161

6262
1. Add the following to your COM map (`BEGIN_COM_MAP ... END_COM_MAP`):
6363

@@ -96,7 +96,7 @@ Note that `IRowsetUpdateImpl` derives from `IRowsetChangeImpl`. Thus, `IRowsetUp
9696
You can find the values used in these macro calls by looking in Atldb.h for the property IDs and values (if Atldb.h differs from the online documentation, Atldb.h supersedes the documentation).
9797

9898
> [!NOTE]
99-
> Many of the `VARIANT_FALSE` and `VARIANT_TRUE` settings are required by the OLE DB templates; the OLE DB specification says they can be read/write, but the OLE DB templates can only support one value.
99+
> Many of the `VARIANT_FALSE` and `VARIANT_TRUE` settings are required by the OLE DB templates; the OLE DB specification says they can be read/write, but the OLE DB templates can only support one value.
100100

101101
**If you implement IRowsetChangeImpl**
102102

@@ -129,16 +129,14 @@ Note that `IRowsetUpdateImpl` derives from `IRowsetChangeImpl`. Thus, `IRowsetUp
129129
- `DBPROP_MAXPENDINGROWS`.
130130

131131
> [!NOTE]
132-
> If you support notifications, you might also have some other properties as well; see the section on `IRowsetNotifyCP` for this list.
132+
> If you support notifications, you might also have some other properties as well; see the section on `IRowsetNotifyCP` for this list.
133133

134134
## <a name="vchowwritingtothedatasource"></a> Writing to the Data Source
135135

136136
To read from the data source, call the `Execute` function. To write to the data source, call the `FlushData` function. (In a general sense, flush means to save modifications you make to a table or index to disk.)
137137

138138
```cpp
139-
140139
FlushData(HROW, HACCESSOR);
141-
142140
```
143141
144142
The row handle (HROW) and accessor handle (HACCESSOR) arguments allow you to specify the region to write. Typically, you write a single data field at a time.
@@ -179,7 +177,7 @@ Handling NULL values.
179177
180178
### Handling default values.
181179
182-
To implement your own FlushData method, you need to:
180+
To implement your own `FlushData` method, you need to:
183181
184182
- Go to your rowset class.
185183
@@ -194,7 +192,7 @@ To implement your own FlushData method, you need to:
194192

195193
- Provide an implementation of `FlushData`.
196194

197-
A good implementation of FlushData stores only the rows and columns that are actually updated. You can use the HROW and HACCESSOR parameters to determine the current row and column being stored for optimization.
195+
A good implementation of `FlushData` stores only the rows and columns that are actually updated. You can use the HROW and HACCESSOR parameters to determine the current row and column being stored for optimization.
198196

199197
Typically, the biggest challenge is working with your own native data store. If possible, try to:
200198

@@ -206,7 +204,7 @@ Typically, the biggest challenge is working with your own native data store. If
206204

207205
The best thing to do is to have actual specified values in your data store for NULL and default values. It is best if you can extrapolate this data. If not, you are advised not to allow NULL and default values.
208206

209-
The following example shows how `FlushData` is implemented in the RUpdateRowset class in the UpdatePV sample (see Rowset.h in the sample code):
207+
The following example shows how `FlushData` is implemented in the `RUpdateRowset` class in the `UpdatePV` sample (see Rowset.h in the sample code):
210208

211209
```cpp
212210
///////////////////////////////////////////////////////////////////////////
@@ -361,16 +359,15 @@ ATLCOLUMNINFO* CommonGetColInfo(IUnknown* pPropsUnk, ULONG* pcCols, bool bBookma
361359
362360
return _rgColumns;
363361
}
364-
365362
```
366363

367364
### Default Values
368365

369366
As with NULL data, you have the responsibility to deal with changing default values.
370367

371-
The default of FlushData and Execute is to return S_OK. Therefore, if you do not override this function, the changes appear to succeed (S_OK will be returned), but they will not be transmitted to the data store.
368+
The default of `FlushData` and `Execute` is to return S_OK. Therefore, if you do not override this function, the changes appear to succeed (S_OK will be returned), but they will not be transmitted to the data store.
372369

373-
In the UpdatePV sample (in Rowset.h), the `SetDBStatus` method handles default values as follows:
370+
In the `UpdatePV` sample (in Rowset.h), the `SetDBStatus` method handles default values as follows:
374371

375372
```cpp
376373
virtual HRESULT SetDBStatus(DBSTATUS* pdbStatus, CSimpleRow* pRow,
@@ -409,11 +406,11 @@ virtual HRESULT SetDBStatus(DBSTATUS* pdbStatus, CSimpleRow* pRow,
409406
410407
### Column Flags
411408
412-
If you support default values on your columns, you need to set it using metadata in the \<provider class\>SchemaRowset class. Set `m_bColumnHasDefault` = VARIANT_TRUE.
409+
If you support default values on your columns, you need to set it using metadata in the \<provider class\>SchemaRowset class. Set `m_bColumnHasDefault = VARIANT_TRUE`.
413410
414411
You also have the responsibility to set the column flags, which are specified using the DBCOLUMNFLAGS enumerated type. The column flags describe column characteristics.
415412
416-
For example, in the `CUpdateSessionColSchemaRowset` class in UpdatePV (in Session.h), the first column is set up this way:
413+
For example, in the `CUpdateSessionColSchemaRowset` class in `UpdatePV` (in Session.h), the first column is set up this way:
417414
418415
```cpp
419416
// Set up column 1

docs/data/oledb/data-sources-and-sessions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Data Sources and Sessions | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "11/04/2016"
4+
ms.date: "10/22/2018"
55
ms.technology: ["cpp-data"]
66
ms.topic: "reference"
77
dev_langs: ["C++"]
@@ -22,7 +22,7 @@ The classes are:
2222

2323
- [CDataSource](../../data/oledb/cdatasource-class.md) This class instantiates the data source object, which creates and manages a connection to a data source through an OLE DB provider. The data source takes information such as the data source address and authentication information in the form of a connection string.
2424

25-
It is also worth noting that the helper class [CEnumerator](../../data/oledb/cenumerator-class.md) is often used before any connection is established to obtain a list of available providers registered on a system. This allows you to select a provider as a data source. For example, the **Data Link Properties** dialog box uses this class to populate the list of providers on the **Providers** tab. It is equivalent to the `SQLBrowseConnect` or `SQLDriverConnect` function.
25+
It's also worth noting that the helper class [CEnumerator](../../data/oledb/cenumerator-class.md) is often used before any connection is established to obtain a list of available providers registered on a system. This allows you to select a provider as a data source. For example, the **Data Link Properties** dialog box uses this class to populate the list of providers on the **Providers** tab. It equates to the `SQLBrowseConnect` or `SQLDriverConnect` function.
2626

2727
- [CSession](../../data/oledb/csession-class.md) This class instantiates the session object, which represents a single access session to the data source. However, you can create multiple sessions on a data source. For each session, you can create rowsets, commands, and other objects to access data from the data source. The session handles transactions.
2828

docs/data/oledb/debugging-your-provider.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ There are two ways to debug your provider:
1919

2020
- You can use the ITEST utility that comes with Visual C++.
2121

22-
### To use the ITEST utility
22+
## To use the ITEST utility
2323

2424
1. Open the provider project.
2525

docs/data/oledb/dynamically-binding-columns-in-your-provider.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Make sure you really need dynamic column binding. You might need it because:
1919

2020
- You support an element such as bookmarks that adds columns.
2121

22-
### To implement dynamic column binding
22+
## To implement dynamic column binding
2323

2424
1. Remove any `PROVIDER_COLUMN_MAP`s from your code.
2525

docs/data/oledb/dynamically-determining-columns-returned-to-the-consumer.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ ms.workload: ["cplusplus", "data-storage"]
1515

1616
The PROVIDER_COLUMN_ENTRY macros normally handle the `IColumnsInfo::GetColumnsInfo` call. However, because a consumer might choose to use bookmarks, the provider must be able to change the columns returned depending on whether the consumer asks for a bookmark.
1717

18-
To handle the `IColumnsInfo::GetColumnsInfo` call, delete the PROVIDER_COLUMN_MAP, which defines a function `GetColumnInfo`, from the `CAgentMan` user record in MyProviderRS.h and replace it with the definition for your own `GetColumnInfo` function:
18+
To handle the `IColumnsInfo::GetColumnsInfo` call, delete the PROVIDER_COLUMN_MAP, which defines a function `GetColumnInfo`, from the `CAgentMan` user record in *Custom*RS.h and replace it with the definition for your own `GetColumnInfo` function:
1919

2020
```cpp
2121
////////////////////////////////////////////////////////////////////////
22-
// MyProviderRS.H
22+
// CustomRS.H
2323
class CAgentMan
2424
{
2525
public:
@@ -40,13 +40,13 @@ public:
4040

4141
Next, implement the `GetColumnInfo` function in MyProviderRS.cpp, as shown in the following code.
4242

43-
`GetColumnInfo` checks first to see if the OLE DB property `DBPROP_BOOKMARKS` is set. To get the property, `GetColumnInfo` uses a pointer (`pRowset`) to the rowset object. The `pThis` pointer represents the class that created the rowset, which is the class where the property map is stored. `GetColumnInfo` typecasts the `pThis` pointer to an `RMyProviderRowset` pointer.
43+
`GetColumnInfo` checks first to see if the OLE DB property `DBPROP_BOOKMARKS` is set. To get the property, `GetColumnInfo` uses a pointer (`pRowset`) to the rowset object. The `pThis` pointer represents the class that created the rowset, which is the class where the property map is stored. `GetColumnInfo` typecasts the `pThis` pointer to an `RCustomRowset` pointer.
4444

4545
To check for the `DBPROP_BOOKMARKS` property, `GetColumnInfo` uses the `IRowsetInfo` interface, which you can obtain by calling `QueryInterface` on the `pRowset` interface. As an alternative, you can use an ATL [CComQIPtr](../../atl/reference/ccomqiptr-class.md) method instead.
4646

4747
```cpp
4848
////////////////////////////////////////////////////////////////////
49-
// MyProviderRS.cpp
49+
// CustomRS.cpp
5050
ATLCOLUMNINFO* CAgentMan::GetColumnInfo(void* pThis, ULONG* pcCols)
5151
{
5252
static ATLCOLUMNINFO _rgColumns[5];
@@ -107,7 +107,7 @@ This example uses a static array to contain the column information. If the consu
107107
108108
```cpp
109109
////////////////////////////////////////////////////////////////////////
110-
// MyProviderRS.h
110+
// CustomRS.h
111111
112112
#define ADD_COLUMN_ENTRY(ulCols, name, ordinal, colSize, type, precision, scale, guid, dataClass, member) \
113113
_rgColumns[ulCols].pwszName = (LPOLESTR)name; \

0 commit comments

Comments
 (0)