description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Learn more about: Macros and Global Functions for OLE DB Consumer Templates |
Macros and Global Functions for OLE DB Consumer Templates |
02/11/2019 |
|
|
8765eb7b-32dd-407c-bacf-8890ef959837 |
The OLE DB Consumer Templates include the following macros and global functions:
Name | Description |
---|---|
AtlTraceErrorRecords | Dumps OLE DB Error Record information to the dump device if an error is returned. |
Name | Description |
---|---|
BEGIN_ACCESSOR | Marks the beginning of an accessor entry. |
BEGIN_ACCESSOR_MAP | Marks the beginning of the accessor map entries. |
END_ACCESSOR | Marks the end of an accessor entry. |
END_ACCESSOR_MAP | Marks the end of the accessor map entries. |
Name | Description |
---|---|
BEGIN_COLUMN_MAP | Marks the beginning of the column map entries in the user record class. |
BLOB_ENTRY | Used to bind a binary large object (BLOB). |
BLOB_ENTRY_LENGTH | Reports the length of the BLOB data column. |
BLOB_ENTRY_LENGTH_STATUS | Reports the length and status of the BLOB data column. |
BLOB_ENTRY_STATUS | Reports the status of the BLOB data column. |
BLOB_NAME | Used to bind a binary large object by column name. |
BLOB_NAME_LENGTH | Reports the length of the BLOB data column. |
BLOB_NAME_LENGTH_STATUS | Reports the length and status of the BLOB data column. |
BLOB_NAME_STATUS | Reports the status of the BLOB data column. |
BOOKMARK_ENTRY | Represents a bookmark entry on the rowset. A bookmark entry is a special kind of column entry. |
COLUMN_ENTRY | Represents a binding to a specific column in the database. |
COLUMN_ENTRY_EX | Represents a binding to the specific column in the database. Supports type, length, precision, scale, and status parameters. |
COLUMN_ENTRY_LENGTH | Represents a binding to the specific column in the database. Supports the length variable. |
COLUMN_ENTRY_LENGTH_STATUS | Represents a binding to the specific column in the database. Supports status and length parameters. |
COLUMN_ENTRY_PS | Represents a binding to the specific column in the database. Supports precision and scale parameters. |
COLUMN_ENTRY_PS_LENGTH | Represents a binding to the specific column in the database. Supports the length variable, precision and scale parameters. |
COLUMN_ENTRY_PS_LENGTH_STATUS | Represents a binding to the specific column in the database. Supports status and length variables, precision and scale parameters. |
COLUMN_ENTRY_PS_STATUS | Represents a binding to the specific column in the database. Supports the status variable, precision and scale parameters. |
COLUMN_ENTRY_STATUS | Represents a binding to the specific column in the database. Supports the status variable. |
COLUMN_ENTRY_TYPE | Represents a binding to a specific column in the database. Supports type parameter. |
COLUMN_ENTRY_TYPE_SIZE | Represents a binding to the specific column in the database. Supports type and size parameters. |
COLUMN_NAME | Represents a binding to a specific column in the database by name. |
COLUMN_NAME_EX | Represents a binding to a specific column in the database by name. Supports specification of data type, size, precision, scale, column length, and column status. |
COLUMN_NAME_LENGTH | Represents a binding to a specific column in the database by name. Supports specification of column length. |
COLUMN_NAME_LENGTH_STATUS | Represents a binding to a specific column in the database by name. Supports specification of column length and status. |
COLUMN_NAME_PS | Represents a binding to a specific column in the database by name. Supports specification of precision and scale. |
COLUMN_NAME_PS_LENGTH | Represents a binding to a specific column in the database by name. Supports specification of precision, scale, and column length. |
COLUMN_NAME_PS_LENGTH_STATUS | Represents a binding to a specific column in the database by name. Supports specification of precision, scale, column length, and column status. |
COLUMN_NAME_PS_STATUS | Represents a binding to a specific column in the database by name. Supports specification of precision, scale, and column status. |
COLUMN_NAME_STATUS | Represents a binding to a specific column in the database by name. Supports specification of column status. |
COLUMN_NAME_TYPE | Represents a binding to a specific column in the database by name. Supports specification of data type. |
COLUMN_NAME_TYPE_PS | Represents a binding to a specific column in the database by name. Supports specification of data type, precision, and scale. |
COLUMN_NAME_TYPE_SIZE | Represents a binding to a specific column in the database by name. Supports specification of data type and size. |
COLUMN_NAME_TYPE_STATUS | Represents a binding to a specific column in the database by name. Supports specification of data type and column status. |
END_COLUMN_MAP | Marks the end of the column map entries. |
Name | Description |
---|---|
DEFINE_COMMAND | Specifies the command that will be used to create the rowset when using the CCommand class. Accepts only string types matching the specified application type (ANSI or Unicode). It is recommended that you use DEFINE_COMMAND_EX instead of DEFINE_COMMAND. |
DEFINE_COMMAND_EX | Specifies the command that will be used to create the rowset when using the CCommand class. Supports ANSI and Unicode applications. |
Name | Description |
---|---|
BEGIN_PARAM_MAP | Marks the beginning of the parameter map entries in the user record class. |
END_PARAM_MAP | Marks the end of the parameter map entries. |
SET_PARAM_TYPE | Specifies COLUMN_ENTRY macros that follow the SET_PARAM_TYPE macro as input, output, or input/output. |
Dumps OLE DB Error Record information to the dump device if an error is returned.
inline void AtlTraceErrorRecords(HRESULT hrErr = S_OK);
hErr
[in] An HRESULT returned by an OLE DB Consumer Template member function.
If hErr is not S_OK, AtlTraceErrorRecords
dumps OLE DB Error Record information to the dump device (the Debug tab of the Output window or a file). The Error Record information, which is obtained from the provider, includes row number, source, description, help file, context, and GUID for each error record entry. AtlTraceErrorRecords
dumps this information only in debug builds. In release builds, it is an empty stub that is optimized out. For more information, see CDBErrorInfo Class.
Marks the beginning of an accessor entry.
BEGIN_ACCESSOR(num, bAuto)
num
[in] The zero-offset number for the accessor in this accessor map.
bAuto
[in] Specifies if this accessor is an auto accessor or a manual accessor. If true
, the accessor is auto; if false
, the accessor is manual. An auto accessor means data is fetched for you on move operations.
In the case of multiple accessors on a rowset, you need to specify BEGIN_ACCESSOR_MAP and use the BEGIN_ACCESSOR macro for each individual accessor. The BEGIN_ACCESSOR macro is completed with the END_ACCESSOR macro. The BEGIN_ACCESSOR_MAP macro is completed with the END_ACCESSOR_MAP macro.
See BEGIN_ACCESSOR_MAP.
Marks the beginning of the accessor map entries.
BEGIN_ACCESSOR_MAP(x, num)
x
[in] The name of the user record class.
num
[in] The number of accessors in this accessor map.
In the case of multiple accessors on a rowset, you need to specify BEGIN_ACCESSOR_MAP at the beginning and use the BEGIN_ACCESSOR macro for each individual accessor. The BEGIN_ACCESSOR macro is completed with the END_ACCESSOR macro. The accessor map is completed with the END_ACCESSOR_MAP macro.
If you have only one accessor in the user record, use the macro BEGIN_COLUMN_MAP.
class CArtistsAccessor
{
public:
// Data Elements
TCHAR m_szFirstName[21];
TCHAR m_szLastName[31];
short m_nAge;
// Output binding map
BEGIN_ACCESSOR_MAP(CArtistsAccessor, 2)
BEGIN_ACCESSOR(0, true)
COLUMN_ENTRY(1, m_szFirstName)
COLUMN_ENTRY(2, m_szLastName)
END_ACCESSOR()
BEGIN_ACCESSOR(1, false) // Not an auto accessor
COLUMN_ENTRY(3, m_nAge)
END_ACCESSOR()
END_ACCESSOR_MAP()
HRESULT OpenDataSource()
{
CDataSource _db;
_db.Open();
return m_session.Open(_db);
}
void CloseDataSource()
{
m_session.Close();
}
CSession m_session;
DEFINE_COMMAND_EX(CArtistsAccessor, L" \
SELECT \
FirstName, \
LastName, \
Age \
FROM Artists")
};
Marks the end of an accessor entry.
END_ACCESSOR()
For multiple accessors on a rowset, you need to specify BEGIN_ACCESSOR_MAP and use the BEGIN_ACCESSOR macro for each individual accessor. The BEGIN_ACCESSOR macro is completed with the END_ACCESSOR macro. The BEGIN_ACCESSOR_MAP macro is completed with the END_ACCESSOR_MAP macro.
See BEGIN_ACCESSOR_MAP.
Marks the end of the accessor map entries.
END_ACCESSOR_MAP()
For multiple accessors on a rowset, you need to specify BEGIN_ACCESSOR_MAP and use the BEGIN_ACCESSOR macro for each individual accessor. The BEGIN_ACCESSOR macro is completed with the END_ACCESSOR macro. The BEGIN_ACCESSOR_MAP macro is completed with the END_ACCESSOR_MAP macro.
See BEGIN_ACCESSOR_MAP.
Marks the beginning of a column map entry.
BEGIN_COLUMN_MAP(x)
x
[in] The name of the user record class derived from CAccessor
.
This macro is used in the case of a single accessor on a rowset. If you have multiple accessors on a rowset, use BEGIN_ACCESSOR_MAP.
The BEGIN_COLUMN_MAP macro is completed with the END_COLUMN_MAP macro. This macro is used when there is only one accessor required in the user record.
Columns correspond to fields in the rowset you want to bind.
Here is a sample column and parameter map:
Used with BEGIN_COLUMN_MAP and END_COLUMN_MAP to bind a binary large object (BLOB).
BLOB_ENTRY(nOrdinal, IID, flags, data)
nOrdinal
[in] The column number.
IID
[in] Interface GUID, such as IDD_ISequentialStream
, used to retrieve the BLOB.
flags
[in] Storage-mode flags as defined by the OLE Structured Storage model (for example, STGM_READ
).
data
[in] The corresponding data member in the user record.
See How Can I Retrieve a BLOB?.
Used with BEGIN_COLUMN_MAP and END_COLUMN_MAP to bind a binary large object (BLOB). Similar to BLOB_ENTRY, except that this macro also gets the length in bytes of the BLOB column.
BLOB_ENTRY_LENGTH(nOrdinal, IID, flags, data, length)
nOrdinal
[in] The column number.
IID
[in] Interface GUID, such as IDD_ISequentialStream
, used to retrieve the BLOB.
flags
[in] Storage-mode flags as defined by the OLE Structured Storage model (for example, STGM_READ
).
data
[in] The corresponding data member in the user record.
length
[out] The (actual) length in bytes of the BLOB column.
See How Can I Retrieve a BLOB?.
Used with BEGIN_COLUMN_MAP and END_COLUMN_MAP to bind a binary large object (BLOB). Similar to BLOB_ENTRY, except that this macro also gets the length and status of the BLOB column.
BLOB_ENTRY_LENGTH_STATUS(
nOrdinal,
IID,
flags,
data,
length,
status )
nOrdinal
[in] The column number.
IID
[in] Interface GUID, such as IDD_ISequentialStream
, used to retrieve the BLOB.
flags
[in] Storage-mode flags as defined by the OLE Structured Storage model (for example, STGM_READ
).
data
[in] The corresponding data member in the user record.
length
[out] The (actual) length in bytes of the BLOB column.
status
[out] The status of the BLOB data column.
See How Can I Retrieve a BLOB?.
Used with BEGIN_COLUMN_MAP or BEGIN_ACCESSOR_MAP to bind a binary large object (BLOB). Similar to BLOB_ENTRY, except that this macro also gets the status of the BLOB column.
BLOB_ENTRY_STATUS(nOrdinal, IID, flags, data, status)
nOrdinal
[in] The column number.
IID
[in] Interface GUID, such as IDD_ISequentialStream
, used to retrieve the BLOB.
flags
[in] Storage-mode flags as defined by the OLE Structured Storage model (for example, STGM_READ
).
data
[in] The corresponding data member in the user record.
status
[out] The status of the BLOB field.
See How Can I Retrieve a BLOB?.
Used with BEGIN_COLUMN_MAP and END_COLUMN_MAP to bind a binary large object (BLOB). Similar to BLOB_ENTRY, except that this macro takes a column name instead of a column number.
BLOB_NAME(pszName, IID, flags, data )
pszName
[in] A pointer to the column name. The name must be a Unicode string. You can accomplish this by putting an 'L' in front of the name, for example: L"MyColumn"
.
IID
[in] Interface GUID, such as IDD_ISequentialStream
, used to retrieve the BLOB.
flags
[in] Storage-mode flags as defined by the OLE Structured Storage model (for example, STGM_READ
).
data
[in] The corresponding data member in the user record.
See How Can I Retrieve a BLOB?.
Used with BEGIN_COLUMN_MAP and END_COLUMN_MAP to bind a binary large object (BLOB). Similar to BLOB_NAME, except that this macro also gets the length in bytes of the BLOB data column.
BLOB_NAME_LENGTH(pszName, IID, flags, data, length )
pszName
[in] A pointer to the column name. The name must be a Unicode string. You can accomplish this by putting an 'L' in front of the name, for example: L"MyColumn"
.
IID
[in] Interface GUID, such as IDD_ISequentialStream
, used to retrieve the BLOB.
flags
[in] Storage-mode flags as defined by the OLE Structured Storage model (for example, STGM_READ
).
data
[in] The corresponding data member in the user record.
length
[out] The (actual) length in bytes of the BLOB column.
Used with BEGIN_COLUMN_MAP and END_COLUMN_MAP to bind a binary large object (BLOB). Similar to BLOB_NAME, except that this macro also gets the length and status of the BLOB data column.
BLOB_NAME_LENGTH_STATUS(pszName, IID, flags, data, length, status )
pszName
[in] A pointer to the column name. The name must be a Unicode string. You can accomplish this by putting an 'L' in front of the name, for example: L"MyColumn"
.
IID
[in] Interface GUID, such as IDD_ISequentialStream
, used to retrieve the BLOB.
flags
[in] Storage-mode flags as defined by the OLE Structured Storage model (for example, STGM_READ
).
data
[in] The corresponding data member in the user record.
length
[out] The (actual) length in bytes of the BLOB column.
status
[out] The status of the BLOB field.
Used with BEGIN_COLUMN_MAP and END_COLUMN_MAP to bind a binary large object (BLOB). Similar to BLOB_NAME, except that this macro also gets the status of the BLOB data column.
BLOB_NAME_STATUS(pszName, IID, flags, data, status )
pszName
[in] A pointer to the column name. The name must be a Unicode string. You can accomplish this by putting an 'L' in front of the name, for example: L"MyColumn"
.
IID
[in] Interface GUID, such as IDD_ISequentialStream
, used to retrieve the BLOB.
flags
[in] Storage-mode flags as defined by the OLE Structured Storage model (for example, STGM_READ
).
data
[in] The corresponding data member in the user record.
status
[out] The status of the BLOB field.
Binds the bookmark column.
BOOKMARK_ENTRY(variable)
variable
[in] The variable to be bound to the bookmark column.
class CArtistsBookmark
{
public:
// Data Elements
CBookmark<4> m_bookmark;
short m_nAge;
TCHAR m_szFirstName[21];
TCHAR m_szLastName[31];
// Output binding map
BEGIN_COLUMN_MAP(CArtistsBookmark)
BOOKMARK_ENTRY(m_bookmark)
COLUMN_ENTRY(1, m_nAge)
COLUMN_ENTRY(2, m_szFirstName)
COLUMN_ENTRY(3, m_szLastName)
END_COLUMN_MAP()
void GetRowsetProperties(CDBPropSet* pPropSet)
{
pPropSet->AddProperty(DBPROP_BOOKMARKS, true);
}
HRESULT OpenDataSource()
{
CDataSource _db;
_db.Open();
return m_session.Open(_db);
}
void CloseDataSource()
{
m_session.Close();
}
CSession m_session;
DEFINE_COMMAND_EX(CArtistsBookmark, L" \
SELECT \
Age, \
FirstName, \
LastName \
FROM Artists")
};
For more information, see Using Bookmarks and CBookmark Class.
Represents a binding on the rowset to the specific column in the rowset.
COLUMN_ENTRY(nOrdinal, data)
See DBBINDING in the OLE DB Programmer's Reference.
nOrdinal
[in] The column number.
data
[in] The corresponding data member in the user record.
The COLUMN_ENTRY macro is used in the following places:
-
Between the BEGIN_COLUMN_MAP and END_COLUMN_MAP macros.
-
Between the BEGIN_ACCESSOR and END_ACCESSOR macros.
-
Between the BEGIN_PARAM_MAP and END_PARAM_MAP macros.
See the examples in the macro topics, BEGIN_COLUMN_MAP and BEGIN_ACCESSOR_MAP.
Represents a binding on the rowset to the specific column in the database.
COLUMN_ENTRY_EX(nOrdinal, wType, nLength, nPrecision, nScale, data, length, status)
See DBBINDING in the OLE DB Programmer's Reference.
nOrdinal
[in] The column number.
wType
[in] The data type.
nLength
[in] The data size in bytes.
nPrecision
[in] The maximum precision to use when getting data and wType is DBTYPE_NUMERIC
. Otherwise, this parameter is ignored.
nScale
[in] The scale to use when getting data and wType is DBTYPE_NUMERIC
or DBTYPE_DECIMAL
.
data
[in] The corresponding data member in the user record.
length
[in] The variable to be bound to the column length.
status
[in] The variable to be bound to the column status.
The COLUMN_ENTRY_EX macro is used in the following places:
-
Between the BEGIN_COLUMN_MAP and END_COLUMN_MAP macros.
-
Between the BEGIN_ACCESSOR and END_ACCESSOR macros.
-
Between the BEGIN_PARAM_MAP and END_PARAM_MAP macros.
See BOOKMARK_ENTRY.
Represents a binding on the rowset to the specific column in the database.
COLUMN_ENTRY_LENGTH(nOrdinal, data, length)
See DBBINDING in the OLE DB Programmer's Reference.
nOrdinal
[in] The column number, starting with one. Bookmark corresponds to column zero.
data
[in] The corresponding data member in the user record.
length
[in] The variable to be bound to the column length.
This macro supports the length variable. It is used in the following places:
-
Between the BEGIN_COLUMN_MAP and END_COLUMN_MAP macros.
-
Between the BEGIN_ACCESSOR and END_ACCESSOR macros.
-
Between the BEGIN_PARAM_MAP and END_PARAM_MAP macros.
Represents a binding on the rowset to the specific column in the database.
COLUMN_ENTRY_LENGTH_STATUS(nOrdinal, data, length, status)
See DBBINDING in the OLE DB Programmer's Reference.
nOrdinal
[in] The column number.
data
[in] The corresponding data member in the user record.
length
[in] The variable to be bound to the column length.
status
[in] The variable to be bound to the column status.
Use this macro when you want to support length and status variables. It is used in the following places:
-
Between the BEGIN_COLUMN_MAP and END_COLUMN_MAP macros.
-
Between the BEGIN_ACCESSOR and END_ACCESSOR macros.
-
Between the BEGIN_PARAM_MAP and END_PARAM_MAP macros.
Represents a binding on the rowset to the specific column in the rowset.
COLUMN_ENTRY_PS(nOrdinal, nPrecision, nScale, data)
See DBBINDING in the OLE DB Programmer's Reference.
nOrdinal
[in] The column number.
nPrecision
[in] The maximum precision of the column you want to bind.
nScale
[in] The scale of the column you want to bind.
data
[in] The corresponding data member in the user record.
Allows you to specify the precision and scale of the column you want to bind. It is used in the following places:
-
Between the BEGIN_COLUMN_MAP and END_COLUMN_MAP macros.
-
Between the BEGIN_ACCESSOR and END_ACCESSOR macros.
-
Between the BEGIN_PARAM_MAP and END_PARAM_MAP macros.
Represents a binding on the rowset to the specific column in the database.
COLUMN_ENTRY_PS_LENGTH(nOrdinal, nPrecision, nScale, data, length)
See DBBINDING in the OLE DB Programmer's Reference.
nOrdinal
[in] The column number, starting with one. Bookmark corresponds to column zero.
nPrecision
[in] The maximum precision of the column you want to bind.
nScale
[in] The scale of the column you want to bind.
data
[in] The corresponding data member in the user record.
length
[in] The variable to be bound to the column length.
Allows you to specify the precision and scale of the column you want to bind. This macro supports the length variable. It is used in the following places:
-
Between the BEGIN_COLUMN_MAP and END_COLUMN_MAP macros.
-
Between the BEGIN_ACCESSOR and END_ACCESSOR macros.
-
Between the BEGIN_PARAM_MAP and END_PARAM_MAP macros.
Represents a binding on the rowset to the specific column in the database.
COLUMN_ENTRY_PS_LENGTH_STATUS(nOrdinal, nPrecision, nScale, data, length, status)
See DBBINDING in the OLE DB Programmer's Reference.
nOrdinal
[in] The column number.
nPrecision
[in] The maximum precision of the column you want to bind.
nScale
[in] The scale of the column you want to bind.
data
[in] The corresponding data member in the user record.
length
[in] The variable to be bound to the column length.
status
[in] The variable to be bound to the column status.
Allows you to specify the precision and scale of the column you want to bind. Use this macro when you want to support length and status variables. It is used in the following places:
-
Between the BEGIN_COLUMN_MAP and END_COLUMN_MAP macros.
-
Between the BEGIN_ACCESSOR and END_ACCESSOR macros.
-
Between the BEGIN_PARAM_MAP and END_PARAM_MAP macros.
Represents a binding on the rowset to the specific column in the database.
COLUMN_ENTRY_PS_STATUS(nOrdinal, nPrecision, nScale, data, status)
See DBBINDING in the OLE DB Programmer's Reference.
nOrdinal
[in] The column number.
nPrecision
[in] The maximum precision of the column you want to bind.
nScale
[in] The scale of the column you want to bind.
data
[in] The corresponding data member in the user record.
status
[in] The variable to be bound to the column status.
Allows you to specify the precision and scale of the column you want to bind. This macro supports the status variable. It is used in the following places:
-
Between the BEGIN_COLUMN_MAP and END_COLUMN_MAP macros.
-
Between the BEGIN_ACCESSOR and END_ACCESSOR macros.
-
Between the BEGIN_PARAM_MAP and END_PARAM_MAP macros.
Represents a binding on the rowset to the specific column in the database.
COLUMN_ENTRY_STATUS(nOrdinal, data, status)
See DBBINDING in the OLE DB Programmer's Reference.
nOrdinal
[in] The column number.
data
[in] The corresponding data member in the user record.
status
[in] The variable to be bound to the column status.
This macro supports the status variable. It is used in the following places:
-
Between the BEGIN_COLUMN_MAP and END_COLUMN_MAP macros.
-
Between the BEGIN_ACCESSOR and END_ACCESSOR macros.
-
Between the BEGIN_PARAM_MAP and END_PARAM_MAP macros.
Represents a binding to the specific column in the database. Supports type parameter.
COLUMN_ENTRY_TYPE (nOrdinal, wType, data)
nOrdinal
[in] The column number.
wType
[in] Data type of column entry.
data
[in] The corresponding data member in the user record.
This macro is a specialized variant of the COLUMN_ENTRY macro that provides a means of specifying data type.
Represents a binding to the specific column in the database. Supports type and size parameters.
COLUMN_ENTRY_TYPE_SIZE(nOrdinal, wType, nLength, data)
nOrdinal
[in] The column number.
wType
[in] Data type of column entry.
nLength
[in] Size of column entry in bytes.
data
[in] The corresponding data member in the user record.
This macro is a specialized variant of the COLUMN_ENTRY macro that provides a means of specifying data size and type.
Represents a binding on the rowset to the specific column in the rowset. Similar to COLUMN_ENTRY, except that this macro takes the column name instead of the column number.
COLUMN_NAME(pszName, data)
pszName
[in] A pointer to the column name. The name must be a Unicode string. You can accomplish this by putting an 'L' in front of the name, for example: L"MyColumn"
.
data
[in] The corresponding data member in the user record.
The COLUMN_NAME_* macros are used in the same places as COLUMN_ENTRY:
-
Between the BEGIN_COLUMN_MAP and END_COLUMN_MAP macros.
-
Between the BEGIN_ACCESSOR and END_ACCESSOR macros.
-
Between the BEGIN_PARAM_MAP and END_PARAM_MAP macros.
Represents a binding on the rowset to the specific column in the rowset. Similar to COLUMN_NAME, except that this macro also takes data type, size, precision, scale, column length, and column status.
COLUMN_NAME_EX(pszName, wType, nLength, nPrecision, nScale, data, length, status )
pszName
[in] A pointer to the column name. The name must be a Unicode string. You can accomplish this by putting an 'L' in front of the name, for example: L"MyColumn"
.
wType
[in] The data type.
nLength
[in] The data size in bytes.
nPrecision
[in] The maximum precision to use when getting data and wType is DBTYPE_NUMERIC
. Otherwise, this parameter is ignored.
nScale
[in] The scale to use when getting data and wType is DBTYPE_NUMERIC
or DBTYPE_DECIMAL
.
data
[in] The corresponding data member in the user record.
length
[in] The variable to be bound to the column length.
status
[in] The variable to be bound to the column status.
See COLUMN_NAME for information on where the COLUMN_NAME_* macros are used.
Represents a binding on the rowset to the specific column in the rowset. Similar to COLUMN_NAME, except that this macro also takes column length.
COLUMN_NAME_LENGTH(pszName, data, length)
pszName
[in] A pointer to the column name. The name must be a Unicode string. You can accomplish this by putting an 'L' in front of the name, for example: L"MyColumn"
.
data
[in] The corresponding data member in the user record.
length
[in] The variable to be bound to the column length.
See COLUMN_NAME for information on where the COLUMN_NAME_* macros are used.
Represents a binding on the rowset to the specific column in the rowset. Similar to COLUMN_NAME, except that this macro also takes column length and column status.
COLUMN_NAME_LENGTH_STATUS(pszName, data, length, status )
pszName
[in] A pointer to the column name. The name must be a Unicode string. You can accomplish this by putting an 'L' in front of the name, for example: L"MyColumn"
.
data
[in] The corresponding data member in the user record.
length
[in] The variable to be bound to the column length.
status
[in] The variable to be bound to the column status.
See COLUMN_NAME for information on where the COLUMN_NAME_* macros are used.
Represents a binding on the rowset to the specific column in the rowset. Similar to COLUMN_NAME, except that this macro also takes precision and scale.
COLUMN_NAME_PS(pszName, nPrecision, nScale, data )
pszName
[in] A pointer to the column name. The name must be a Unicode string. You can accomplish this by putting an 'L' in front of the name, for example: L"MyColumn"
.
nPrecision
[in] The maximum precision of the column you want to bind.
nScale
[in] The scale of the column you want to bind.
data
[in] The corresponding data member in the user record.
See COLUMN_NAME for information on where the COLUMN_NAME_* macros are used.
Represents a binding on the rowset to the specific column in the rowset. Similar to COLUMN_NAME, except that this macro also takes precision, scale, and column length.
COLUMN_NAME_PS_LENGTH(pszName, nPrecision, nScale, data, length )
pszName
[in] A pointer to the column name. The name must be a Unicode string. You can accomplish this by putting an 'L' in front of the name, for example: L"MyColumn"
.
nPrecision
[in] The maximum precision of the column you want to bind.
nScale
[in] The scale of the column you want to bind.
data
[in] The corresponding data member in the user record.
length
[in] The variable to be bound to the column length.
See COLUMN_NAME for information on where the COLUMN_NAME_* macros are used.
Represents a binding on the rowset to the specific column in the rowset. Similar to COLUMN_NAME, except that this macro also takes precision, scale, column length, and column status.
COLUMN_NAME_PS_LENGTH_STATUS(pszName, nPrecision, nScale, data, length, status )
pszName
[in] A pointer to the column name. The name must be a Unicode string. You can accomplish this by putting an 'L' in front of the name, for example: L"MyColumn"
.
nPrecision
[in] The maximum precision of the column you want to bind.
nScale
[in] The scale of the column you want to bind.
data
[in] The corresponding data member in the user record.
length
[in] The variable to be bound to the column length.
status
[in] The variable to be bound to the column status.
See COLUMN_NAME for information on where the COLUMN_NAME_* macros are used.
Represents a binding on the rowset to the specific column in the rowset. Similar to COLUMN_NAME, except that this macro also takes precision, scale, and column status.
COLUMN_NAME_PS_STATUS(pszName, nPrecision, nScale, data, status )
pszName
[in] A pointer to the column name. The name must be a Unicode string. You can accomplish this by putting an 'L' in front of the name, for example: L"MyColumn"
.
nPrecision
[in] The maximum precision of the column you want to bind.
nScale
[in] The scale of the column you want to bind.
data
[in] The corresponding data member in the user record.
status
[in] The variable to be bound to the column status.
See COLUMN_NAME for information on where the COLUMN_NAME_* macros are used.
Represents a binding on the rowset to the specific column in the rowset. Similar to COLUMN_NAME, except that this macro also takes column status.
COLUMN_NAME_STATUS(pszName, data, status )
pszName
[in] A pointer to the column name. The name must be a Unicode string. You can accomplish this by putting an 'L' in front of the name, for example: L"MyColumn"
.
data
[in] The corresponding data member in the user record.
status
[in] The variable to be bound to the column status.
See COLUMN_NAME for information on where the COLUMN_NAME_* macros are used.
Represents a binding on the rowset to the specific column in the rowset. Similar to COLUMN_NAME, except that this macro also takes data type.
COLUMN_NAME_TYPE(pszName, wType, data)
pszName
[in] A pointer to the column name. The name must be a Unicode string. You can accomplish this by putting an 'L' in front of the name, for example: L"MyColumn"
.
wType
[in] The data type.
data
[in] The corresponding data member in the user record.
See COLUMN_NAME for information on where the COLUMN_NAME_* macros are used.
Represents a binding on the rowset to the specific column in the rowset. Similar to COLUMN_NAME, except that this macro also takes data type, precision, and scale.
COLUMN_NAME_TYPE_PS(pszName, wType, nPrecision, nScale, data)
pszName
[in] A pointer to the column name. The name must be a Unicode string. You can accomplish this by putting an 'L' in front of the name, for example: L"MyColumn"
.
wType
[in] The data type.
nPrecision
[in] The maximum precision to use when getting data and wType is DBTYPE_NUMERIC
. Otherwise, this parameter is ignored.
nScale
[in] The scale to use when getting data and wType is DBTYPE_NUMERIC
or DBTYPE_DECIMAL
.
data
[in] The corresponding data member in the user record.
See COLUMN_NAME for information on where the COLUMN_NAME_* macros are used.
Represents a binding on the rowset to the specific column in the rowset. Similar to COLUMN_NAME, except that this macro also takes data type and size.
COLUMN_NAME_TYPE_SIZE(pszName, wType, nLength, data)
pszName
[in] A pointer to the column name. The name must be a Unicode string. You can accomplish this by putting an 'L' in front of the name, for example: L"MyColumn"
.
wType
[in] The data type.
nLength
[in] The data size in bytes.
data
[in] The corresponding data member in the user record.
See COLUMN_NAME for information on where the COLUMN_NAME_* macros are used.
Represents a binding on the rowset to the specific column in the rowset. Similar to COLUMN_NAME, except that this macro also takes data type and column status.
COLUMN_NAME_TYPE_STATUS(pszName, wType, status, data)
pszName
[in] A pointer to the column name. The name must be a Unicode string. You can accomplish this by putting an 'L' in front of the name, for example: L"MyColumn"
.
wType
[in] The data type.
status
[in] The variable to be bound to the column status.
data
[in] The corresponding data member in the user record.
See COLUMN_NAME for information on where the COLUMN_NAME_* macros are used.
Marks the end of the column map entries.
END_COLUMN_MAP()
It is used with a single accessor on a rowset. The BEGIN_COLUMN_MAP macro is completed with the END_COLUMN_MAP macro.
See BEGIN_COLUMN_MAP.
Specifies the command that will be used to create the rowset when using the CCommand class. Accepts only string types matching the specified application type (ANSI or Unicode).
Note
It is recommended that you use DEFINE_COMMAND_EX instead of DEFINE_COMMAND.
DEFINE_COMMAND(x, szCommand)
x
[in] The name of the user record (command) class.
szCommand
[in] The command string that will be used to create the rowset when using CCommand.
The command string that you specify will be used as the default if you do not specify command text in the CCommand::Open method.
This macro accepts ANSI strings if you build your application as ANSI, or Unicode strings if you build your application as Unicode. It is recommended that you use DEFINE_COMMAND_EX instead of DEFINE_COMMAND, because the former accepts Unicode strings, regardless of the ANSI or Unicode application type.
See BOOKMARK_ENTRY.
Specifies the command that will be used to create the rowset when using the CCommand class. Supports Unicode and ANSI applications.
DEFINE_COMMAND_EX(x, wszCommand)
x
[in] The name of the user record (command) class.
wszCommand
[in] The command string that will be used to create the rowset when using CCommand.
The command string that you specify will be used as the default if you do not specify command text in the CCommand::Open method.
This macro accepts Unicode strings, regardless of the application type. This macro is preferred over DEFINE_COMMAND because it supports Unicode as well as ANSI applications.
See BOOKMARK_ENTRY.
Marks the beginning of the parameter map entries.
BEGIN_PARAM_MAP(x)
x
[in] The name of the user record class.
Parameters are used by commands.
See the example for the BEGIN_COLUMN_MAP macro.
Marks the end of the parameter map entries.
END_PARAM_MAP()
See the example for the BEGIN_PARAM_MAP macro.
Specifies COLUMN_ENTRY macros that follow the SET_PARAM_TYPE macro input, output, or input/output.
SET_PARAM_TYPE(type)
type
[in] The type to set for the parameter.
Providers support only parameter input/output types that are supported by the underlying data source. The type is a combination of one or more DBPARAMIO
values (see DBBINDING Structures in the OLE DB Programmer's Reference):
-
DBPARAMIO_NOTPARAM
The accessor has no parameters. Typically, you seteParamIO
to this value in row accessors to remind the user that parameters are ignored. -
DBPARAMIO_INPUT
An input parameter. -
DBPARAMIO_OUTPUT
An output parameter. -
DBPARAMIO_INPUT | DBPARAMIO_OUTPUT
The parameter is both an input and an output parameter.
class CArtistsProperty
{
public:
short m_nReturn;
short m_nAge;
TCHAR m_szFirstName[21];
TCHAR m_szLastName[31];
BEGIN_PARAM_MAP(CArtistsProperty)
SET_PARAM_TYPE(DBPARAMIO_OUTPUT)
COLUMN_ENTRY(1, m_nReturn)
SET_PARAM_TYPE(DBPARAMIO_INPUT)
COLUMN_ENTRY(2, m_nAge)
END_PARAM_MAP()
BEGIN_COLUMN_MAP(CArtistsProperty)
COLUMN_ENTRY(1, m_szFirstName)
COLUMN_ENTRY(2, m_szLastName)
END_COLUMN_MAP()
HRESULT OpenDataSource()
{
CDataSource _db;
_db.Open();
return m_session.Open(_db);
}
void CloseDataSource()
{
m_session.Close();
}
CSession m_session;
DEFINE_COMMAND_EX(CArtistsProperty, L" \
{ ? = SELECT Age FROM Artists WHERE Age < ? }")
};
Header: atldbcli.h
Macros and Global Functions for OLE DB Consumer Templates
OLE DB Consumer Templates
OLE DB Consumer Templates Reference