OLEDBTextConsumerSet.h
上传用户:benben_wyd
上传日期:2010-02-26
资源大小:1229k
文件大小:3k
源码类别:

书籍源码

开发平台:

Visual C++

  1. // OLEDBTextConsumerSet.h : interface of the COLEDBTextConsumerSet class
  2. //
  3. /////////////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_OLEDBTEXTCONSUMERSET_H__1A082C0E_C8D8_11D2_9949_D68A87749F4B__INCLUDED_)
  5. #define AFX_OLEDBTEXTCONSUMERSET_H__1A082C0E_C8D8_11D2_9949_D68A87749F4B__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. class CMy
  10. {
  11. public:
  12. CMy()
  13. {
  14. memset( (void*)this, 0, sizeof(*this) );
  15. };
  16. TCHAR m_strClass[51];
  17. TCHAR m_strSectionID[12];
  18. TCHAR m_strYear[7];
  19. TCHAR m_strTerm[31];
  20. TCHAR m_strInstructor[51];
  21. TCHAR m_strAssignment[256];
  22. TCHAR m_strScore[23];
  23. TCHAR m_strStudent[36];
  24. BEGIN_COLUMN_MAP(CMy)
  25. COLUMN_ENTRY_TYPE(1, DBTYPE_STR, m_strClass)
  26. COLUMN_ENTRY_TYPE(2, DBTYPE_STR, m_strSectionID)
  27. COLUMN_ENTRY_TYPE(3, DBTYPE_STR, m_strYear)
  28. COLUMN_ENTRY_TYPE(4, DBTYPE_STR, m_strTerm)
  29. COLUMN_ENTRY_TYPE(5, DBTYPE_STR, m_strInstructor)
  30. COLUMN_ENTRY_TYPE(6, DBTYPE_STR, m_strAssignment)
  31. COLUMN_ENTRY_TYPE(7, DBTYPE_STR, m_strScore)
  32. COLUMN_ENTRY_TYPE(8, DBTYPE_STR, m_strStudent)
  33. END_COLUMN_MAP()
  34. };
  35. class COLEDBTextConsumerSet : public CCommand<CAccessor<CMy> >
  36. {
  37. public:
  38. HRESULT Open()
  39. {
  40. CDataSource db;
  41. CSession session;
  42. HRESULT hr;
  43. CDBPropSet dbinit(DBPROPSET_DBINIT);
  44. dbinit.AddProperty(DBPROP_AUTH_PASSWORD, "");
  45. dbinit.AddProperty(DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO, false);
  46. dbinit.AddProperty(DBPROP_AUTH_USERID, "");
  47. dbinit.AddProperty(DBPROP_INIT_DATASOURCE, "");
  48. dbinit.AddProperty(DBPROP_INIT_LCID, (long)0);
  49. dbinit.AddProperty(DBPROP_INIT_LOCATION, "");
  50. dbinit.AddProperty(DBPROP_INIT_MODE, (long)0);
  51. dbinit.AddProperty(DBPROP_INIT_PROMPT, (short)2);
  52. dbinit.AddProperty(DBPROP_INIT_PROVIDERSTRING, "");
  53. dbinit.AddProperty(DBPROP_INIT_TIMEOUT, (long)0);
  54. hr = db.OpenWithServiceComponents("OLEDBTextProvider.OLEDBTextProvider.1", &dbinit);
  55. if (FAILED(hr))
  56. return hr;
  57. hr = session.Open(db);
  58. if (FAILED(hr))
  59. return hr;
  60. CDBPropSet propset(DBPROPSET_ROWSET);
  61. propset.AddProperty(DBPROP_CANFETCHBACKWARDS, true);
  62. propset.AddProperty(DBPROP_IRowsetScroll, true);
  63. propset.AddProperty(DBPROP_IRowsetChange, true);
  64. propset.AddProperty(DBPROP_UPDATABILITY, DBPROPVAL_UP_CHANGE | DBPROPVAL_UP_INSERT | DBPROPVAL_UP_DELETE );
  65. hr = CCommand<CAccessor<CMy> >::Open(session, " ", &propset);
  66. if (FAILED(hr))
  67. return hr;
  68. return MoveNext();
  69. }
  70. };
  71. //{{AFX_INSERT_LOCATION}}
  72. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  73. #endif // !defined(AFX_OLEDBTEXTCONSUMERSET_H__1A082C0E_C8D8_11D2_9949_D68A87749F4B__INCLUDED_)