Skip to content

Commit fa46f26

Browse files
author
msebolt
committed
oledb tutorial review consumer
1 parent 4b5ea95 commit fa46f26

22 files changed

Lines changed: 92 additions & 97 deletions

docs/data/oledb/accessing-xml-data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ myCmd.m_spStream->Read()
4747

4848
SQL Server 2000 does the XML formatting and returns all columns and all rows of the rowset as one XML string.
4949

50-
For an example using the `Read` method, see "Adding XML Support to the Consumer" in [Implementing a Simple Consumer](../../data/oledb/implementing-a-simple-consumer.md).
50+
For an example using the `Read` method, see **Adding XML Support to the Consumer** in [Implementing a Simple Consumer](../../data/oledb/implementing-a-simple-consumer.md).
5151

5252
> [!NOTE]
5353
> XML support using `CStreamRowset` works with SQL Server 2000 only and requires that you have the OLE DB Provider for SQL Server 2000 (installed with MDAC).

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ When you use the **ATL OLE DB Consumer Wizard** to generate a consumer, you have
1717

1818
- 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

20-
- 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).
20+
- 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'll 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

2222
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

@@ -144,9 +144,9 @@ class CProducts : public CCommand<CAccessor<CProductsAccessor>>
144144
145145
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
147-
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.
147+
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 can't create a copy constructor this way, because it can't directly instantiate the `COrdersAccessor` object. If you need a constructor (or other method) directly on the `COrders` class, it's recommended that you define a new class deriving from `COrders` and add the necessary methods there.
148148
149-
In the following example, the wizard generates a declaration for the class `COrders`, but the user record class `COrdersAccessor` does not appear, because the attributes inject it.
149+
In the following example, the wizard generates a declaration for the class `COrders`, but the user record class `COrdersAccessor` doesn't appear, because the attributes inject it.
150150
151151
```cpp
152152
#define _ATL_ATTRIBUTES

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ ms.workload: ["cplusplus", "data-storage"]
1313
---
1414
# Consumer Wizard-Generated Methods
1515

16-
The ATL OLE DB Consumer Wizard and the MFC Application Wizard generate certain functions of which you should be aware. Note that some methods are implemented differently in attributed projects, so there are a few caveats; each case is covered below. For information about viewing injected code, see [Debugging Injected Code](/visualstudio/debugger/how-to-debug-injected-code).
16+
The **ATL OLE DB Consumer Wizard** and the **MFC Application Wizard** generate certain functions of which you should be aware. Some methods are implemented differently in attributed projects, so there are a few caveats; each case is covered below. For information about viewing injected code, see [Debugging Injected Code](/visualstudio/debugger/how-to-debug-injected-code).
1717

18-
- `OpenAll` opens the data source, rowsets, and turns on bookmarks if they are available.
18+
- `OpenAll` opens the data source, rowsets, and turns on bookmarks if they're available.
1919

2020
- `CloseAll` closes all open rowsets and releases all command executions.
2121

@@ -70,7 +70,7 @@ int main(int argc, char* argv[])
7070
7171
## Remarks
7272
73-
Note that if you define a `HasBookmark` method, the `OpenAll` code sets the `DBPROP_IRowsetLocate` property; make sure you only do this if your provider supports that property.
73+
If you define a `HasBookmark` method, the `OpenAll` code sets the `DBPROP_IRowsetLocate` property; make sure you only do this if your provider supports that property.
7474
7575
## OpenRowset
7676
@@ -81,7 +81,7 @@ HRESULT OpenRowset(DBPROPSET* pPropSet = NULL)
8181
HRESULT OpenRowset(const CSession& session, LPCWSTR szCommand = NULL);
8282
```
8383

84-
`OpenAll` calls this method to open the rowset or rowsets in the consumer. Typically, you do not need to call `OpenRowset` unless you want to work with multiple data sources/sessions/rowsets. `OpenRowset` is declared in the command or table class header file:
84+
`OpenAll` calls this method to open the rowset or rowsets in the consumer. Typically, you don't need to call `OpenRowset` unless you want to work with multiple data sources/sessions/rowsets. `OpenRowset` is declared in the command or table class header file:
8585

8686
```cpp
8787
// OLE DB Template version:
@@ -96,7 +96,7 @@ HRESULT OpenRowset(DBPROPSET *pPropSet = NULL)
9696
}
9797
```
9898
99-
The attributes implement this method differently. This version takes a session object and a command string that defaults to the command string specified in db_command, although you can pass a different one. Note that if you define a `HasBookmark` method, the `OpenRowset` code sets the `DBPROP_IRowsetLocate` property; make sure you only do this if your provider supports that property.
99+
The attributes implement this method differently. This version takes a session object and a command string that defaults to the command string specified in db_command, although you can pass a different one. If you define a `HasBookmark` method, the `OpenRowset` code sets the `DBPROP_IRowsetLocate` property; make sure you only do this if your provider supports that property.
100100
101101
```cpp
102102
// Attribute-injected version:
@@ -135,7 +135,7 @@ void GetRowsetProperties(CDBPropSet* pPropSet)
135135

136136
## Remarks
137137

138-
You should not define a global `GetRowsetProperties` method because it could conflict with the one defined by the wizard. Note that this is a wizard-generated method that you get with templated and attributed projects; the attributes do not inject this code.
138+
You shouldn't define a global `GetRowsetProperties` method because it could conflict with the one defined by the wizard. This is a wizard-generated method that you get with templated and attributed projects; the attributes don't inject this code.
139139

140140
## OpenDataSource and CloseDataSource
141141

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ ms.workload: ["cplusplus", "data-storage"]
1313
---
1414
# Creating a Consumer Without Using a Wizard
1515

16-
The following example assumes that you are adding OLE DB consumer support to an existing ATL project. If you want to add OLE DB consumer support to an MFC application, you should run the MFC Application Wizard, which creates all the support necessary and invokes MFC routines necessary to execute the application.
16+
The following example assumes that you're adding OLE DB consumer support to an existing ATL project. If you want to add OLE DB consumer support to an MFC application, you should run the **MFC Application Wizard**, which creates all the support necessary and invokes MFC routines necessary to execute the application.
1717

18-
To add OLE DB consumer support without using the ATL OLE DB Consumer Wizard:
18+
To add OLE DB consumer support without using the **ATL OLE DB Consumer Wizard**:
1919

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

@@ -40,7 +40,7 @@ Programmatically, a consumer typically performs the following sequence of operat
4040
class CMyTableName : public CCommand<CAccessor<CMyTableNameAccessor>>
4141
```
4242

43-
- Call `CoInitialize` to initialize COM. This is usually called in the main code. For example:
43+
- Call `CoInitialize` to initialize COM. This is called in the main code. For example:
4444

4545
```cpp
4646
HRESULT hr = CoInitialize(NULL);
@@ -70,7 +70,7 @@ Programmatically, a consumer typically performs the following sequence of operat
7070

7171
If you are using a command, you might want to call `ReleaseCommand` after `Close`. The code example in [CCommand::Close](../../data/oledb/ccommand-close.md) shows how to call `Close` and `ReleaseCommand`.
7272

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

7575
```cpp
7676
CoUninitialize();

docs/data/oledb/creating-a-simple-consumer.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ms.workload: ["cplusplus", "data-storage"]
1313
---
1414
# Creating a Simple Consumer
1515

16-
Use the ATL Project Wizard and ATL OLE DB Consumer Wizard to generate an OLE DB Templates consumer.
16+
Use the **ATL Project Wizard** and **ATL OLE DB Consumer Wizard** to generate an OLE DB Templates consumer.
1717

1818
## To create a console application for an OLE DB consumer
1919

@@ -31,7 +31,7 @@ Use the ATL Project Wizard and ATL OLE DB Consumer Wizard to generate an OLE DB
3131

3232
1. Click **OK** to close the wizard and generate the project.
3333

34-
Next, use the ATL OLE DB Consumer Wizard to add an OLE DB consumer object.
34+
Next, use the **ATL OLE DB Consumer Wizard** to add an OLE DB consumer object.
3535

3636
## To create a consumer with the ATL OLE DB Consumer Wizard
3737

@@ -43,34 +43,34 @@ Next, use the ATL OLE DB Consumer Wizard to add an OLE DB consumer object.
4343

4444
1. In the **Categories** pane, click **Installed** > **Visual C++** > **ATL**, click the **ATL OLEDB Consumer** icon in the **Templates** pane, and then click **Add**.
4545

46-
The ATL OLEDB Consumer Wizard appears.
46+
The **ATL OLEDB Consumer Wizard** appears.
4747

4848
1. Click the **Data Source** button.
4949

5050
The **Data Link Properties** dialog box appears.
5151

5252
1. In the **Data Link Properties** dialog box, do the following:
5353

54-
- On the **Provider** tab, specify an OLE DB provider.
54+
1. On the **Provider** tab, specify an OLE DB provider.
5555

56-
- On the **Connection** tab, specify the required information, such as server name, logon ID, and password for your data source and database on the server.
56+
1. On the **Connection** tab, specify the required information, such as server name, logon ID, and password for your data source and database on the server.
5757

58-
> [!NOTE]
59-
> There is a security issue with the **Allow saving password** feature of the **Data Link Properties** dialog box. In **Enter information to log on to the server**, there are two radio buttons: **Use Windows NT integrated security** and **Use a specific user name and password**.
58+
> [!NOTE]
59+
> There is a security issue with the **Allow saving password** feature of the **Data Link Properties** dialog box. In **Enter information to log on to the server**, there are two radio buttons: **Use Windows NT integrated security** and **Use a specific user name and password**.
60+
61+
> [!NOTE]
62+
> If you select **Use a specific user name and password**, you have the option of saving the password (using the **Allow saving password** check box); however, this option is not secure. It is recommended that you select **Use Windows NT integrated security**; this option uses Windows NT to verify your identity.
63+
64+
> [!NOTE]
65+
> If you cannot use Windows NT integrated security, you should use a middle-tier application to prompt the user for the password or to store the password in a location with security mechanisms to help protect it (instead of in source code).
6066
61-
> [!NOTE]
62-
> If you select **Use a specific user name and password**, you have the option of saving the password (using the **Allow saving password** check box); however, this option is not secure. It is recommended that you select **Use Windows NT integrated security**; this option uses Windows NT to verify your identity.
63-
64-
> [!NOTE]
65-
> If you cannot use Windows NT integrated security, you should use a middle-tier application to prompt the user for the password or to store the password in a location with security mechanisms to help protect it (instead of in source code).
66-
67-
After selecting your provider and other settings, click **Test Connection** to verify the selections made on the previous dialog box pages. If the **Results** box reports `Test connection succeeded`, click **OK** to create the data link.
67+
1. After selecting your provider and other settings, click **Test Connection** to verify the selections made on the previous dialog box pages. If the **Results** box reports `Test connection succeeded`, click **OK** to create the data link.
6868

6969
The **Select Database Object** dialog box appears.
7070

71-
1. Use the tree control to select a table, view, or stored procedure. For the purpose of this procedure, select the `Products` table from the `Northwind` database.
71+
1. Use the tree control to select a table, view, or stored procedure. For this example, select the `Products` table from the `Northwind` database.
7272

73-
1. Click **OK**. This returns you to the ATL OLE DB Consumer Wizard.
73+
1. Click **OK**. This returns you to the **ATL OLE DB Consumer Wizard**.
7474

7575
1. The wizard completes the names for `Class` and **.h file** based on the name of the table, view, or stored procedure that you selected. You can edit these names if you want.
7676

@@ -82,14 +82,14 @@ Next, use the ATL OLE DB Consumer Wizard to add an OLE DB consumer object.
8282

8383
1. Under **Support**, leave the **Change**, **Insert**, and **Delete** boxes cleared.
8484

85-
Select the **Change**, **Insert**, and **Delete** check boxes to support the changing, inserting, and deleting of records in the rowset, if required. For more information about writing data to the data store, see [Updating Rowsets](../../data/oledb/updating-rowsets.md).
85+
Select the **Change**, **Insert**, and **Delete** check boxes to support the changing, inserting, and deleting of records in the rowset. For more information about writing data to the data store, see [Updating Rowsets](../../data/oledb/updating-rowsets.md).
8686

8787
1. Click **Finish** to create the consumer.
8888

8989
The wizard generates a command class and a user record class, as shown in [Consumer Wizard-Generated Classes](../../data/oledb/consumer-wizard-generated-classes.md). The command class will have the name that you entered in the `Class` box in the wizard (in this case, `CProducts`), and the user record class will have a name of the form "*ClassName*Accessor" (in this case, `CProductsAccessor`).
9090

9191
> [!NOTE]
92-
> The wizard puts the following line into Products.h:
92+
> The wizard puts the following line into `Products.h`:
9393
9494
```cpp
9595
#error Security Issue: The connection string may contain a password

docs/data/oledb/defining-stored-procedures.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ BEGIN_PARAM_MAP(CMySProcAccessor)
3232
END_PARAM_MAP()
3333
```
3434

35-
The previous example defines a stored procedure as it goes. Typically, for efficient reuse of code, a database contains a set of predefined stored procedures with names such as "Sales by Year" or "dt_adduserobject." You can view their definitions using SQL Server Enterprise Manager. You call them as follows (the placement of the '?' parameters depend on the stored procedure's interface):
35+
The previous example defines a stored procedure as it goes. Typically, for efficient reuse of code, a database contains a set of predefined stored procedures with names such as `Sales by Year` or `dt_adduserobject`. You can view their definitions using SQL Server Enterprise Manager. You call them as follows (the placement of the *?* parameters depend on the stored procedure's interface):
3636

3737
```cpp
3838
DEFINE_COMMAND(CMySProcAccessor, _T("{CALL \"Sales by Year\" (?,?) }")

0 commit comments

Comments
 (0)