You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/data/oledb/accessing-xml-data.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,7 +47,7 @@ myCmd.m_spStream->Read()
47
47
48
48
SQL Server 2000 does the XML formatting and returns all columns and all rows of the rowset as one XML string.
49
49
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).
51
51
52
52
> [!NOTE]
53
53
> 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).
Copy file name to clipboardExpand all lines: docs/data/oledb/consumer-wizard-generated-classes.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ When you use the **ATL OLE DB Consumer Wizard** to generate a consumer, you have
17
17
18
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.
19
19
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).
21
21
22
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.
23
23
@@ -144,9 +144,9 @@ class CProducts : public CCommand<CAccessor<CProductsAccessor>>
144
144
145
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.
146
146
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.
148
148
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.
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).
17
17
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.
19
19
20
20
-`CloseAll` closes all open rowsets and releases all command executions.
21
21
@@ -70,7 +70,7 @@ int main(int argc, char* argv[])
70
70
71
71
## Remarks
72
72
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.
`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:
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.
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.
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.
17
17
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**:
19
19
20
20
- In your pch.h file, append the following `#include` statements:
21
21
@@ -40,7 +40,7 @@ Programmatically, a consumer typically performs the following sequence of operat
- 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:
44
44
45
45
```cpp
46
46
HRESULT hr = CoInitialize(NULL);
@@ -70,7 +70,7 @@ Programmatically, a consumer typically performs the following sequence of operat
70
70
71
71
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`.
72
72
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.
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.
17
17
18
18
## To create a console application for an OLE DB consumer
19
19
@@ -31,7 +31,7 @@ Use the ATL Project Wizard and ATL OLE DB Consumer Wizard to generate an OLE DB
31
31
32
32
1. Click **OK** to close the wizard and generate the project.
33
33
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.
35
35
36
36
## To create a consumer with the ATL OLE DB Consumer Wizard
37
37
@@ -43,34 +43,34 @@ Next, use the ATL OLE DB Consumer Wizard to add an OLE DB consumer object.
43
43
44
44
1. In the **Categories** pane, click **Installed** > **Visual C++** > **ATL**, click the **ATL OLEDB Consumer** icon in the **Templates** pane, and then click **Add**.
45
45
46
-
The ATL OLEDB Consumer Wizard appears.
46
+
The **ATL OLEDB Consumer Wizard** appears.
47
47
48
48
1. Click the **Data Source** button.
49
49
50
50
The **Data Link Properties** dialog box appears.
51
51
52
52
1. In the **Data Link Properties** dialog box, do the following:
53
53
54
-
- On the **Provider** tab, specify an OLE DB provider.
54
+
1. On the **Provider** tab, specify an OLE DB provider.
55
55
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.
57
57
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).
60
66
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.
68
68
69
69
The **Select Database Object** dialog box appears.
70
70
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.
72
72
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**.
74
74
75
75
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.
76
76
@@ -82,14 +82,14 @@ Next, use the ATL OLE DB Consumer Wizard to add an OLE DB consumer object.
82
82
83
83
1. Under **Support**, leave the **Change**, **Insert**, and **Delete** boxes cleared.
84
84
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).
86
86
87
87
1. Click **Finish** to create the consumer.
88
88
89
89
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`).
90
90
91
91
> [!NOTE]
92
-
> The wizard puts the following line into Products.h:
92
+
> The wizard puts the following line into `Products.h`:
93
93
94
94
```cpp
95
95
#error Security Issue: The connection string may contain a password
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):
36
36
37
37
```cpp
38
38
DEFINE_COMMAND(CMySProcAccessor, _T("{CALL \"Sales by Year\" (?,?) }")
0 commit comments