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/odbc/recordset-parameterizing-a-recordset-odbc.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,21 +33,21 @@ This topic applies to the MFC ODBC classes.
33
33
34
34
- It lets you build a query at run time, based on information not available to you at design time, such as information obtained from your user or calculated at run time.
35
35
36
-
When you call **Open** to run the query, the recordset uses the parameter information to complete its **SQL SELECT** statement. You can parameterize any recordset.
36
+
When you call `Open` to run the query, the recordset uses the parameter information to complete its **SQL SELECT** statement. You can parameterize any recordset.
37
37
38
38
## <aname="_core_when_to_use_parameters"></a> When to Use Parameters
39
39
Typical uses for parameters include:
40
40
41
41
- Passing run-time arguments to a predefined query.
42
42
43
-
To pass parameters to a stored procedure, you must specify a complete custom ODBC **CALL** statement — with parameter placeholders — when you call **Open**, overriding the recordset's default SQL statement. For more information, see [CRecordset::Open](../../mfc/reference/crecordset-class.md#open) in the *Class Library Reference* and [SQL: Customizing Your Recordset's SQL Statement (ODBC)](../../data/odbc/sql-customizing-your-recordsets-sql-statement-odbc.md) and [Recordset: Declaring a Class for a Predefined Query (ODBC)](../../data/odbc/recordset-declaring-a-class-for-a-predefined-query-odbc.md).
43
+
To pass parameters to a stored procedure, you must specify a complete custom ODBC **CALL** statement — with parameter placeholders — when you call `Open`, overriding the recordset's default SQL statement. For more information, see [CRecordset::Open](../../mfc/reference/crecordset-class.md#open) in the *Class Library Reference* and [SQL: Customizing Your Recordset's SQL Statement (ODBC)](../../data/odbc/sql-customizing-your-recordsets-sql-statement-odbc.md) and [Recordset: Declaring a Class for a Predefined Query (ODBC)](../../data/odbc/recordset-declaring-a-class-for-a-predefined-query-odbc.md).
44
44
45
45
46
46
- Efficiently performing numerous requeries with different parameter information.
47
47
48
-
For example, each time your end user looks up information for a particular student in the student registration database, you can specify the student's name or ID as a parameter obtained from the user. Then, when you call your recordset's **Requery** member function, the query selects only that student's record.
48
+
For example, each time your end user looks up information for a particular student in the student registration database, you can specify the student's name or ID as a parameter obtained from the user. Then, when you call your recordset's `Requery` member function, the query selects only that student's record.
49
49
50
-
Your recordset's filter string, stored in **m_strFilter**, might look like this:
50
+
Your recordset's filter string, stored in `m_strFilter`, might look like this:
51
51
52
52
```
53
53
"StudentID = ?"
@@ -75,7 +75,7 @@ This topic applies to the MFC ODBC classes.
75
75
The parameter value is different each time you requery the recordset for a new student ID.
76
76
77
77
> [!TIP]
78
-
> Using a parameter is more efficient than simply a filter. For a parameterized recordset, the database must process a SQL **SELECT** statement only once. For a filtered recordset without parameters, the **SELECT** statement must be processed each time you **Requery** with a new filter value.
78
+
> Using a parameter is more efficient than simply a filter. For a parameterized recordset, the database must process a SQL **SELECT** statement only once. For a filtered recordset without parameters, the **SELECT** statement must be processed each time you `Requery` with a new filter value.
79
79
80
80
For more information about filters, see [Recordset: Filtering Records (ODBC)](../../data/odbc/recordset-filtering-records-odbc.md).
81
81
@@ -94,7 +94,7 @@ This topic applies to the MFC ODBC classes.
94
94
95
95
3. After the wizard writes the class to a file in your project, go to the .h file and manually add one or more parameter data members to the class declaration. The addition might look something like the following example, part of a snapshot class designed to answer the query "Which students are in the senior class?"
96
96
97
-
```
97
+
```cpp
98
98
class CStudentSet : public CRecordset
99
99
{
100
100
// Field/Param Data
@@ -132,21 +132,21 @@ This topic applies to the MFC ODBC classes.
132
132
> The most likely string to work with is the string you specify (if any) for the class's [m_strFilter](../../mfc/reference/crecordset-class.md#m_strfilter) data member, but some ODBC drivers might allow parameters in other SQL clauses.
133
133
134
134
## <a name="_core_passing_parameter_values_at_run_time"></a> Passing Parameter Values at Run Time
135
-
You must specify parameter values before you call **Open** (for a new recordset object) or **Requery** (for an existing one).
135
+
You must specify parameter values before you call `Open` (for a new recordset object) or `Requery` (for an existing one).
136
136
137
137
#### To pass parameter values to a recordset object at run time
138
138
139
139
1. Construct the recordset object.
140
140
141
-
2. Prepare a string or strings, such as the **m_strFilter** string, containing the SQL statement, or parts of it. Put "?" placeholders where the parameter information is to go.
141
+
2. Prepare a string or strings, such as the `m_strFilter` string, containing the SQL statement, or parts of it. Put "?" placeholders where the parameter information is to go.
142
142
143
143
3. Assign a run-time parameter value to each parameter data member of the object.
144
144
145
-
4. Call the **Open** member function (or **Requery**, for an existing recordset).
145
+
4. Call the `Open` member function (or `Requery`, for an existing recordset).
146
146
147
147
For example, suppose you want to specify a filter string for your recordset using information obtained at run time. Assume you have constructed a recordset of class `CStudentSet` earlier — called `rsStudents` — and now want to requery it for a particular kind of student information.
Copy file name to clipboardExpand all lines: docs/data/odbc/recordset-requerying-a-recordset-odbc.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
@@ -29,7 +29,7 @@ This topic applies to the MFC ODBC classes.
29
29
Another frequent — and equally important — use of [Requery](../../mfc/reference/crecordset-class.md#requery) is to select a new set of records based on changing parameter values.
30
30
31
31
> [!TIP]
32
-
> Query speed is probably significantly faster if you call **Requery** with changing parameter values than if you call **Open** again.
32
+
> Query speed is probably significantly faster if you call `Requery` with changing parameter values than if you call `Open` again.
33
33
34
34
## <aname="_core_requerying_dynasets_vs.._snapshots"></a> Requerying Dynasets vs. Snapshots
35
35
Because dynasets are meant to present a set of records with dynamic up-to-date data, you want to requery dynasets often if you want to reflect other users' additions. Snapshots, on the other hand, are useful because you can safely rely on their static contents while you prepare reports, calculate totals, and so on. Still, you might sometimes want to requery a snapshot as well. In a multiuser environment, snapshot data might lose synchronization with the data source as other users change the database.
@@ -43,9 +43,9 @@ This topic applies to the MFC ODBC classes.
43
43
For an example, see [Record Views: Filling a List Box from a Second Recordset](../../data/filling-a-list-box-from-a-second-recordset-mfc-data-access.md).
44
44
45
45
> [!TIP]
46
-
> To optimize **Requery** performance, avoid changing the recordset's [filter](../../data/odbc/recordset-filtering-records-odbc.md) or [sort](../../data/odbc/recordset-sorting-records-odbc.md). Change only the parameter value before calling **Requery**.
46
+
> To optimize `Requery` performance, avoid changing the recordset's [filter](../../data/odbc/recordset-filtering-records-odbc.md) or [sort](../../data/odbc/recordset-sorting-records-odbc.md). Change only the parameter value before calling `Requery`.
47
47
48
-
If the **Requery** call fails, you can retry the call; otherwise, your application should terminate gracefully. A call to **Requery** or **Open** might fail for any of a number of reasons. Perhaps a network error occurs; or, during the call, after the existing data is released but before the new data is obtained, another user might get exclusive access; or the table on which your recordset depends could be deleted.
48
+
If the `Requery` call fails, you can retry the call; otherwise, your application should terminate gracefully. A call to `Requery` or `Open` might fail for any of a number of reasons. Perhaps a network error occurs; or, during the call, after the existing data is released but before the new data is obtained, another user might get exclusive access; or the table on which your recordset depends could be deleted.
Copy file name to clipboardExpand all lines: docs/data/odbc/recordset-scrolling-odbc.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,12 +23,12 @@ This topic applies to the MFC ODBC classes.
23
23
-[Under what circumstances scrolling is and is not supported](#_core_when_scrolling_is_supported).
24
24
25
25
## <aname="_core_scrolling_from_one_record_to_another"></a> Scrolling from One Record to Another
26
-
Class `CRecordset` provides the **Move** member functions for scrolling within a recordset. These functions move the current record by rowsets. If you have implemented bulk row fetching, a **Move** operation repositions the recordset by the size of the rowset. If you have not implemented bulk row fetching, a call to a **Move** function repositions the recordset by one record each time. For more information about bulk row fetching, see [Recordset: Fetching Records in Bulk (ODBC)](../../data/odbc/recordset-fetching-records-in-bulk-odbc.md).
26
+
Class `CRecordset` provides the `Move` member functions for scrolling within a recordset. These functions move the current record by rowsets. If you have implemented bulk row fetching, a `Move` operation repositions the recordset by the size of the rowset. If you have not implemented bulk row fetching, a call to a `Move` function repositions the recordset by one record each time. For more information about bulk row fetching, see [Recordset: Fetching Records in Bulk (ODBC)](../../data/odbc/recordset-fetching-records-in-bulk-odbc.md).
27
27
28
28
> [!NOTE]
29
29
> When moving through a recordset, deleted records might not be skipped. For more information, see the [IsDeleted](../../mfc/reference/crecordset-class.md#isdeleted) member function.
30
30
31
-
In addition to the **Move** functions, `CRecordset` provides member functions for checking whether you have scrolled past the end or ahead of the beginning of your recordset.
31
+
In addition to the `Move` functions, `CRecordset` provides member functions for checking whether you have scrolled past the end or ahead of the beginning of your recordset.
32
32
33
33
To determine whether scrolling is possible in your recordset, call the `CanScroll` member function.
34
34
@@ -78,18 +78,18 @@ while( !rsCustSet.IsBOF( ) )
78
78
rsCustSet.MoveFirst( );
79
79
```
80
80
81
-
`IsEOF` returns a nonzero value if the recordset is positioned past the last record. `IsBOF` returns a nonzero value if the recordset is positioned ahead of the first record (before all records). In either case, there is no current record to operate on. If you call `MovePrev` when `IsBOF` is already **TRUE** or call `MoveNext` when `IsEOF` is already **TRUE**, the framework throws a `CDBException`. You can also use `IsBOF` and `IsEOF` to check for an empty recordset.
81
+
`IsEOF` returns a nonzero value if the recordset is positioned past the last record. `IsBOF` returns a nonzero value if the recordset is positioned ahead of the first record (before all records). In either case, there is no current record to operate on. If you call `MovePrev` when `IsBOF` is already TRUE or call `MoveNext` when `IsEOF` is already TRUE, the framework throws a `CDBException`. You can also use `IsBOF` and `IsEOF` to check for an empty recordset.
82
82
83
83
For more information about recordset navigation, see [Recordset: Bookmarks and Absolute Positions (ODBC)](../../data/odbc/recordset-bookmarks-and-absolute-positions-odbc.md).
84
84
85
85
## <aname="_core_when_scrolling_is_supported"></a> When Scrolling Is Supported
86
86
As originally designed, SQL provided only forward scrolling, but ODBC extends scrolling capabilities. The available level of support for scrolling depends on the ODBC drivers your application works with, your driver's ODBC API conformance level, and whether the ODBC Cursor Library is loaded into memory. For more information, see [ODBC](../../data/odbc/odbc-basics.md) and [ODBC: The ODBC Cursor Library](../../data/odbc/odbc-the-odbc-cursor-library.md).
87
87
88
88
> [!TIP]
89
-
> You can control whether the cursor library is used. See the `bUseCursorLib` and `dwOptions` parameters to [CDatabase::Open](../../mfc/reference/cdatabase-class.md#open).
89
+
> You can control whether the cursor library is used. See the *bUseCursorLib* and *dwOptions* parameters to [CDatabase::Open](../../mfc/reference/cdatabase-class.md#open).
90
90
91
91
> [!NOTE]
92
-
> Unlike the MFC DAO classes, the MFC ODBC classes do not provide a set of **Find** functions for locating the next (or previous) record that meets specified criteria.
92
+
> Unlike the MFC DAO classes, the MFC ODBC classes do not provide a set of `Find` functions for locating the next (or previous) record that meets specified criteria.
This topic explains how to sort your recordset. You can specify one or more columns on which to base the sort, and you can specify ascending or descending order (`ASC` or **DESC**; `ASC` is the default) for each specified column. For example, if you specify two columns, the records are sorted first on the first column named and then on the second column named. A SQL **ORDER BY** clause defines a sort. When the framework appends the **ORDER BY** clause to the recordset's SQL query, the clause controls the selection's ordering.
17
+
This topic explains how to sort your recordset. You can specify one or more columns on which to base the sort, and you can specify ascending or descending order (**ASC** or **DESC**; **ASC** is the default) for each specified column. For example, if you specify two columns, the records are sorted first on the first column named and then on the second column named. A SQL **ORDER BY** clause defines a sort. When the framework appends the **ORDER BY** clause to the recordset's SQL query, the clause controls the selection's ordering.
18
18
19
-
You must establish a recordset's sort order after you construct the object but before you call its **Open** member function (or before you call the **Requery** member function for an existing recordset object whose **Open** member function has been called previously).
19
+
You must establish a recordset's sort order after you construct the object but before you call its `Open` member function (or before you call the `Requery` member function for an existing recordset object whose `Open` member function has been called previously).
20
20
21
21
#### To specify a sort order for a recordset object
22
22
23
-
1. Construct a new recordset object (or prepare to call **Requery** for an existing one).
23
+
1. Construct a new recordset object (or prepare to call `Requery` for an existing one).
24
24
25
25
2. Set the value of the object's [m_strSort](../../mfc/reference/crecordset-class.md#m_strsort) data member.
26
26
@@ -38,11 +38,11 @@ This topic applies to the MFC ODBC classes.
38
38
39
39
3. Set any other options you need, such as a filter, locking mode, or parameters.
40
40
41
-
4. Call **Open** for the new object (or **Requery** for an existing object).
41
+
4. Call `Open` for the new object (or `Requery` for an existing object).
42
42
43
43
The selected records are ordered as specified. For example, to sort a set of student records in descending order by last name, then first name, do the following:
44
44
45
-
```
45
+
```cpp
46
46
// Construct the recordset
47
47
CStudentSet rsStudent( NULL );
48
48
// Set the sort
@@ -54,7 +54,7 @@ rsStudent.Open( );
54
54
The recordset contains all of the student records, sorted in descending order (Z to A) by last name, then by first name.
55
55
56
56
> [!NOTE]
57
-
> If you choose to override the recordset's default SQL string by passing your own SQL string to **Open**, do not set a sort if your custom string has an **ORDER BY** clause.
57
+
> If you choose to override the recordset's default SQL string by passing your own SQL string to `Open`, do not set a sort if your custom string has an **ORDER BY** clause.
Copy file name to clipboardExpand all lines: docs/data/odbc/recordset-working-with-large-data-items-odbc.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
@@ -48,7 +48,7 @@ This topic applies to both the MFC ODBC classes and the MFC DAO classes.
48
48
In turn, you use the `HGLOBAL` handle, `m_hData`, to work with the data itself, operating on it as you would on any handle data. This is where [CByteArray](../../mfc/reference/cbytearray-class.md) adds capabilities.
49
49
50
50
> [!CAUTION]
51
-
> CLongBinary objects cannot be used as parameters in function calls. In addition, their implementation, which calls **::SQLGetData**, necessarily slows scrolling performance for a scrollable snapshot. This might also be true when you use an **::SQLGetData** call yourself to retrieve dynamic schema columns.
51
+
> CLongBinary objects cannot be used as parameters in function calls. In addition, their implementation, which calls `::SQLGetData`, necessarily slows scrolling performance for a scrollable snapshot. This might also be true when you use an `::SQLGetData` call yourself to retrieve dynamic schema columns.
0 commit comments