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
After you open the data source, session, and rowset objects, you can fetch data. Depending on the type of accessor you are using, you might need to bind columns.
16
+
After you open the data source, session, and rowset objects, you can fetch data. Depending on the type of accessor you're using, you might need to bind columns.
17
17
18
-
###To fetch data
18
+
## To fetch data
19
19
20
20
1. Open the rowset using the appropriate **Open** command.
21
21
22
-
1. If you are using `CManualAccessor`, bind the output columns if you have not already done so. To bind the columns, call `GetColumnInfo`, and then create an accessor with the bindings, as shown in the following example:
22
+
1. If you're using `CManualAccessor`, bind the output columns if you haven't already done so. The following example is taken from the [DBViewer](https://github.com/Microsoft/VCSamples/tree/master/VC2008Samples/ATL/OLEDB/Consumer/dbviewer) sample. To bind the columns, call `GetColumnInfo`, and then create an accessor with the bindings, as shown in the following example:
23
23
24
24
```cpp
25
25
// From the DBViewer Sample CDBTreeView::OnQueryEdit
@@ -36,7 +36,7 @@ After you open the data source, session, and rowset objects, you can fetch data.
36
36
rs.Bind();
37
37
```
38
38
39
-
1. Write a `while` loop to retrieve the data. In the loop, call `MoveNext` to advance the cursor and test the return value against S_OK, as shown in the following example:
39
+
1. Write a **while** loop to retrieve the data. In the loop, call `MoveNext` to advance the cursor and test the return value against S_OK, as shown in the following example:
40
40
41
41
```cpp
42
42
while (rs.MoveNext() == S_OK)
@@ -46,7 +46,7 @@ After you open the data source, session, and rowset objects, you can fetch data.
46
46
}
47
47
```
48
48
49
-
1. Within the `while` loop, you can fetch the data according to your accessor type.
49
+
1. Within the **while** loop, you can fetch the data according to your accessor type.
50
50
51
51
- If you use the [CAccessor](../../data/oledb/caccessor-class.md) class, you should have a user record that contains data members. You can access your data using those data members, as shown in the following example:
52
52
@@ -60,7 +60,7 @@ After you open the data source, session, and rowset objects, you can fetch data.
60
60
}
61
61
```
62
62
63
-
- If you use the `CDynamicAccessor` or `CDynamicParameterAccessor` class, you can fetch data by using the accessing functions `GetValue` and `GetColumn`, as shown in the following example. If you want to determine the type of data you are using, use `GetType`.
63
+
- If you use the `CDynamicAccessor` or `CDynamicParameterAccessor` class, you can fetch data by using the accessing functions `GetValue` and `GetColumn`, as shown in the following example. If you want to determine the type of data you're using, use `GetType`.
64
64
65
65
```cpp
66
66
while (rs.MoveNext() == S_OK)
@@ -87,6 +87,6 @@ After you open the data source, session, and rowset objects, you can fetch data.
87
87
}
88
88
```
89
89
90
-
## See Also
90
+
## See also
91
91
92
92
[Working with OLE DB Consumer Templates](../../data/oledb/working-with-ole-db-consumer-templates.md)
Copy file name to clipboardExpand all lines: docs/data/oledb/passing-ole-db-conformance-tests.md
-20Lines changed: 0 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,26 +50,6 @@ The code first checks to see whether the property is linked to another. If the p
50
50
51
51
You might also want to add the `IsValidValue` routine to your code. The templates call `IsValidValue` when attempting to set a property. You would override this method if you require additional processing when setting a property value. You can have one of these methods for each property set.
52
52
53
-
## Threading Issues
54
-
55
-
By default, the OLE DB Provider Wizard in the ATL OLE DB Provider Wizard generates code for the provider to run in an apartment model. If you attempt to run this code with the conformance tests, you initially get failures. This is because Ltm.exe, the tool used to run the OLE DB conformance tests, defaults to free threaded. The OLE DB Provider Wizard code defaults to apartment model for performance and ease of use.
56
-
57
-
To correct this problem, you can either change LTM or change the provider.
58
-
59
-
### To change LTM to run in apartment threaded mode
60
-
61
-
1. On the LTM main menu, click **Tools**, and then click **Options**.
62
-
63
-
1. On the **General** tab, change the threading model from **Free Threaded** to **Apartment Threaded**.
64
-
65
-
To change your provider to run in free threaded mode:
66
-
67
-
- In your provider project, search for all instances of `CComSingleThreadModel` and replace it with `CComMultiThreadModel`, which should be in your data source, session, and rowset headers.
68
-
69
-
- In your .rgs file, change the threading model from **Apartment** to **Both**.
70
-
71
-
- Follow correct programming rules for free threaded programming (that is, lock on writes).
The following example shows a quick and easy database access that does not involve commands. The following consumer code, in an ATL project, retrieves records from a table called *Artists* in a Microsoft Access database using the Microsoft OLE DB Provider for ODBC. The code creates a [CTable](../../data/oledb/ctable-class.md) table object with an accessor based on the user record class `CArtists`. It opens a connection, opens a session on the connection, and opens the table on the session.
16
+
The following example shows quick and easy database access that doesn't involve commands. The following consumer code, in an ATL project, retrieves records from a table called *Artists* in a Microsoft Access database using the Microsoft OLE DB Provider for ODBC. The code creates a [CTable](../../data/oledb/ctable-class.md) table object with an accessor based on the user record class `CArtists`. It opens a connection, opens a session on the connection, and opens the table on the session.
17
17
18
18
```cpp
19
19
#include<atldbcli.h>
20
-
21
-
CDataSource connection;
22
-
CSession session;
23
-
CTable<CAccessor<CArtists>> artists;
24
-
25
-
// Open the connection, session, and table, specifying authentication
26
-
// using Windows NT integrated security. Hard-coding a password is a major
0 commit comments