글
Technical Article/펌 2004. 7. 27. 12:30Using Multiple Accessors on a Rowset
Using Multiple Accessors on a Rowset
This example uses multiple accessors to retrieve one set of data. An application might use multiple accessors to optimize data access. The rowset retrieves one block of data that can be used by multiple accessors. (The accessor is defined in OLE DB User Records.)
#include
CDataSource connection;
CSession session;
CTable > artists;
// Connect the database, session, and accessors
connection.Open(CLSID_MSDASQL, "NWind", "sa", "");
session.Open(connection);
artists.Open(session, "artists");
// Retrieve the data
while (artists.MoveNext() == S_OK)
{
cout << artists.m_szFirstName;
cout << artists.m_szLastName;
artists.GetData(1); // Retrieve data for other accessor
cout << artists.m_nAge;
}
The user record looks like this:
class CMultiArtists
{
public:
// Data Elements
CHAR m_szFirstName[20];
CHAR m_szLastName[30];
short m_nAge;
// output binding map
BEGIN_ACCESSOR_MAP(CMultiArtists, 2)
BEGIN_ACCESSOR(0, true)
COLUMN_ENTRY(1, m_szFirstName)
COLUMN_ENTRY(2, m_szLastName)
END_ACCESSOR(0)
BEGIN_ACCESSOR(1, false) // not an auto accessor
COLUMN_ENTRY(3, m_nAge)
END_ACCESSOR()
END_ACCESSOR_MAP()
};
OLEDB접근할때 ATL Consumer를 이용해서 멀티플 엑세서를 사용하는 방법이다. 스크립하고 잘만 연동시키면 view를 대체할수 있는 방법이 되지 않을까 싶다.
This example uses multiple accessors to retrieve one set of data. An application might use multiple accessors to optimize data access. The rowset retrieves one block of data that can be used by multiple accessors. (The accessor is defined in OLE DB User Records.)
#include
CDataSource connection;
CSession session;
CTable
// Connect the database, session, and accessors
connection.Open(CLSID_MSDASQL, "NWind", "sa", "");
session.Open(connection);
artists.Open(session, "artists");
// Retrieve the data
while (artists.MoveNext() == S_OK)
{
cout << artists.m_szFirstName;
cout << artists.m_szLastName;
artists.GetData(1); // Retrieve data for other accessor
cout << artists.m_nAge;
}
The user record looks like this:
class CMultiArtists
{
public:
// Data Elements
CHAR m_szFirstName[20];
CHAR m_szLastName[30];
short m_nAge;
// output binding map
BEGIN_ACCESSOR_MAP(CMultiArtists, 2)
BEGIN_ACCESSOR(0, true)
COLUMN_ENTRY(1, m_szFirstName)
COLUMN_ENTRY(2, m_szLastName)
END_ACCESSOR(0)
BEGIN_ACCESSOR(1, false) // not an auto accessor
COLUMN_ENTRY(3, m_nAge)
END_ACCESSOR()
END_ACCESSOR_MAP()
};
OLEDB접근할때 ATL Consumer를 이용해서 멀티플 엑세서를 사용하는 방법이다. 스크립하고 잘만 연동시키면 view를 대체할수 있는 방법이 되지 않을까 싶다.
![](https://lh3.googleusercontent.com/-hYZb_novCPQ/V5HuGPkGFUI/AAAAAAAAANk/f8zcKkeTBbA1A-W6yuqfk12fs8bd8FeOQCL0B/banner_468_60.png)
RECENT COMMENT