⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 oledbtextconsumerset.h

📁 < VISUAL C++ 数据库编程技术与实例>> 配套源码 人民邮电出版社
💻 H
字号:
// OLEDBTextConsumerSet.h : interface of the COLEDBTextConsumerSet class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_OLEDBTEXTCONSUMERSET_H__1A082C0E_C8D8_11D2_9949_D68A87749F4B__INCLUDED_)
#define AFX_OLEDBTEXTCONSUMERSET_H__1A082C0E_C8D8_11D2_9949_D68A87749F4B__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CMy
{
public:
	CMy()
	{
		memset( (void*)this, 0, sizeof(*this) );
	};
	TCHAR m_strClass[51];
	TCHAR m_strSectionID[12];
	TCHAR m_strYear[7];
	TCHAR m_strTerm[31];
	TCHAR m_strInstructor[51];
	TCHAR m_strAssignment[256];
	TCHAR m_strScore[23];
	TCHAR m_strStudent[36];

BEGIN_COLUMN_MAP(CMy)
		COLUMN_ENTRY_TYPE(1, DBTYPE_STR, m_strClass)
		COLUMN_ENTRY_TYPE(2, DBTYPE_STR, m_strSectionID)
		COLUMN_ENTRY_TYPE(3, DBTYPE_STR, m_strYear)
		COLUMN_ENTRY_TYPE(4, DBTYPE_STR, m_strTerm)
		COLUMN_ENTRY_TYPE(5, DBTYPE_STR, m_strInstructor)
		COLUMN_ENTRY_TYPE(6, DBTYPE_STR, m_strAssignment)
		COLUMN_ENTRY_TYPE(7, DBTYPE_STR, m_strScore)
		COLUMN_ENTRY_TYPE(8, DBTYPE_STR, m_strStudent)
END_COLUMN_MAP()
};

class COLEDBTextConsumerSet : public CCommand<CAccessor<CMy> >
{
public:

	HRESULT Open()
	{
		CDataSource db;
		CSession	session;
		HRESULT		hr;

		CDBPropSet	dbinit(DBPROPSET_DBINIT);
		dbinit.AddProperty(DBPROP_AUTH_PASSWORD, "");
		dbinit.AddProperty(DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO, false);
		dbinit.AddProperty(DBPROP_AUTH_USERID, "");
		dbinit.AddProperty(DBPROP_INIT_DATASOURCE, "");
		dbinit.AddProperty(DBPROP_INIT_LCID, (long)0);
		dbinit.AddProperty(DBPROP_INIT_LOCATION, "");
		dbinit.AddProperty(DBPROP_INIT_MODE, (long)0);
		dbinit.AddProperty(DBPROP_INIT_PROMPT, (short)2);
		dbinit.AddProperty(DBPROP_INIT_PROVIDERSTRING, "");
		dbinit.AddProperty(DBPROP_INIT_TIMEOUT, (long)0);

		hr = db.OpenWithServiceComponents("OLEDBTextProvider.OLEDBTextProvider.1", &dbinit);
		if (FAILED(hr))
			return hr;

		hr = session.Open(db);
		if (FAILED(hr))
			return hr;

		CDBPropSet	propset(DBPROPSET_ROWSET);
		propset.AddProperty(DBPROP_CANFETCHBACKWARDS, true);
		propset.AddProperty(DBPROP_IRowsetScroll, true);
		propset.AddProperty(DBPROP_IRowsetChange, true);
		propset.AddProperty(DBPROP_UPDATABILITY, DBPROPVAL_UP_CHANGE | DBPROPVAL_UP_INSERT | DBPROPVAL_UP_DELETE );

		hr = CCommand<CAccessor<CMy> >::Open(session, " ", &propset);
		if (FAILED(hr))
			return hr;

		return MoveNext();
	}

};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_OLEDBTEXTCONSUMERSET_H__1A082C0E_C8D8_11D2_9949_D68A87749F4B__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -