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

书籍源码

开发平台:

Visual C++

  1. // OLEDBMFCMiscSet.h : interface of the COLEDBMFCMiscSet class
  2. //
  3. /////////////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_OLEDBMFCMISCSET_H__7DEAF56E_AEF0_11D2_9949_C0D1E9AACF44__INCLUDED_)
  5. #define AFX_OLEDBMFCMISCSET_H__7DEAF56E_AEF0_11D2_9949_C0D1E9AACF44__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #include "..OLEDBErrorCheckingOLEDBErrorChecking.h"
  10. class CRowDefinition
  11. {
  12. public:
  13. CRowDefinition()
  14. {
  15. memset( (void*)this, 0, sizeof(*this) );
  16. };
  17. CBookmark<4> m_RowsetBookmark;   // Added by CW for bookmarks
  18. char m_strDepartmentCode[5];
  19. char m_strDepartmentName[51];
  20. BEGIN_COLUMN_MAP(CRowDefinition)
  21.         BOOKMARK_ENTRY(m_RowsetBookmark)   // Added by CW for bookmarks
  22. COLUMN_ENTRY_TYPE(1, DBTYPE_STR, m_strDepartmentCode)
  23. COLUMN_ENTRY_TYPE(2, DBTYPE_STR, m_strDepartmentName)
  24. END_COLUMN_MAP()
  25. };
  26. //class COLEDBMFCMiscSet : public CTable<CAccessor<CRowDefinition>, CRowset >
  27. class COLEDBMFCMiscSet : public CTable<CAccessor<CRowDefinition>, CBulkRowset>
  28. {
  29. public:
  30. ULONG m_lRecordInAccessor;
  31. HRESULT MoveNext();
  32. void DisplayColumnInfo();
  33. char *getType(DBTYPE wType, char* strType);
  34. HRESULT Open()
  35. {
  36. CDataSource db;
  37. CSession session;
  38. HRESULT hr;
  39. m_lRecordInAccessor = 0;
  40. CDBPropSet dbinit(DBPROPSET_DBINIT);
  41. dbinit.AddProperty(DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO, false);
  42. dbinit.AddProperty(DBPROP_INIT_DATASOURCE, "Classes");
  43. dbinit.AddProperty(DBPROP_INIT_PROMPT, (short)4);
  44. dbinit.AddProperty(DBPROP_INIT_LCID, (long)1033);
  45. hr = db.OpenWithServiceComponents("MSDASQL.1", &dbinit);
  46. if (FAILED(hr))
  47. return hr;
  48. hr = session.Open(db);
  49. if (FAILED(hr))
  50. return hr;
  51. CDBPropSet propset(DBPROPSET_ROWSET);
  52. propset.AddProperty(DBPROP_CANFETCHBACKWARDS, true);
  53. propset.AddProperty(DBPROP_IRowsetScroll, true);
  54. propset.AddProperty(DBPROP_IRowsetChange, true);
  55. propset.AddProperty(DBPROP_UPDATABILITY, DBPROPVAL_UP_CHANGE | DBPROPVAL_UP_INSERT | DBPROPVAL_UP_DELETE );
  56. //Added by Chuck Wood for bookmark support
  57.         propset.AddProperty(DBPROP_BOOKMARKS, true);
  58. //Set the number of records in the CBulkRowset
  59. SetRows(3);
  60. // hr = CTable<CAccessor<CRowDefinition>, CBulkRowset >::Open(session, "Grades", &propset);
  61. hr = CTable<CAccessor<CRowDefinition>, CBulkRowset >::Open(session, "Department", &propset);
  62. // hr = CTable<CAccessor<CRowDefinition>, CRowset>::Open(session, "Department", &propset);
  63. if (FAILED(hr))
  64. return hr;
  65. return MoveNext();
  66. }
  67. };
  68. //{{AFX_INSERT_LOCATION}}
  69. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  70. #endif // !defined(AFX_OLEDBMFCMISCSET_H__7DEAF56E_AEF0_11D2_9949_C0D1E9AACF44__INCLUDED_)