CXMLAccessor 클래스
Allows you to access data sources as string data when you have no knowledge of the data store's schema (underlying structure).
class CXMLAccessor : public CDynamicStringAccessorW
멤버
메서드
Retrieves the column information. |
|
Retrieves the entire contents of a table by rows. |
설명
However, CXMLAccessor differs from CDynamicStringAccessorW in that it converts all data accessed from the data store as XML-formatted (tagged) data. This is especially useful for output to XML-aware Web pages. The XML tag names will match the data store's column names as closely as possible.
CDynamicAccessor 메서드를 사용하여 열 정보를 구하십시오. 사용자는 이 열 정보를 사용하여 런타임에 동적으로 접근자를 만듭니다.
열 정보는 이 클래스에서 만들고 관리하는 버퍼에 저장됩니다. Obtain column information using GetXMLColumnData or obtain column data by rows using GetXMLRowData.
예제
void DoCXMLAccessorTest()
{
HRESULT hr = CoInitialize(NULL);
CDataSource ds;
CSession ss;
CTable<CXMLAccessor> rs;
// The following is an example initialization string:
hr = ds.OpenFromInitializationString(L"Provider=Microsoft.Jet.OLEDB.4.0;"
L"User ID=Admin;Data Source=Snippet.mdb;Mode=Share Deny None;"
L"Extended Properties=\"\";Jet OLEDB:System database=\"\";"
L"Jet OLEDB:Registry Path=\"\";Jet OLEDB:Database Password=\"\";"
L"Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;"
L"Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;"
L"Jet OLEDB:New Database Password=\"\";Jet OLEDB:Create System Database=False;"
L"Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;"
L"Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False");
hr = ss.Open(ds);
hr = rs.Open(ss, L"Customer"); // Customer is a table name in the database.
CStringW strColumnInfo;
rs.GetXMLColumnData(strColumnInfo);
wprintf_s(L"%s\n", strColumnInfo);
hr = rs.MoveFirst();
while(SUCCEEDED(hr) && hr != DB_S_ENDOFROWSET)
{
CStringW strRowData;
rs.GetXMLRowData(strRowData);
wprintf_s(L"%s\n", strRowData);
hr = rs.MoveNext();
}
ss.Close();
ds.Close();
CoUninitialize();
}
요구 사항
Header: atldbcli.h