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

📄 sample04set.h

📁 vc百例之四
💻 H
字号:
// Sample04Set.h : interface of the CSample04Set class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_Sample04SET_H__29DB24EF_9CFF_4E01_8A62_416ED3BAD531__INCLUDED_)
#define AFX_Sample04SET_H__29DB24EF_9CFF_4E01_8A62_416ED3BAD531__INCLUDED_

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

class CMy
{
public:
	CMy()
	{
		memset( (void*)this, 0, sizeof(*this) );
	};

	int m_ID;
	wchar_t m_column0[26];
	wchar_t m_column1[26];
	wchar_t m_column2[26];
	wchar_t m_E_mail[26];
	wchar_t m_column3[513];	//TODO: Change this large string to an ISequentialStream if your provider supports it.


BEGIN_COLUMN_MAP(CMy)
		COLUMN_ENTRY_TYPE(1, DBTYPE_I4, m_ID)
		COLUMN_ENTRY_TYPE(2, DBTYPE_WSTR, m_column0)
		COLUMN_ENTRY_TYPE(3, DBTYPE_WSTR, m_column1)
		COLUMN_ENTRY_TYPE(4, DBTYPE_WSTR, m_column2)
		COLUMN_ENTRY_TYPE(5, DBTYPE_WSTR, m_E_mail)
		COLUMN_ENTRY_TYPE(6, DBTYPE_WSTR, m_column3)
END_COLUMN_MAP()

};

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

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

		CDBPropSet	dbinit(DBPROPSET_DBINIT);
		dbinit.AddProperty(DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO, false);
		dbinit.AddProperty(DBPROP_INIT_DATASOURCE, "演示数据库");
		dbinit.AddProperty(DBPROP_INIT_PROMPT, (short)4);
		dbinit.AddProperty(DBPROP_INIT_LCID, (long)2052);

		hr = db.OpenWithServiceComponents("MSDASQL.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, "SELECT * FROM 员工档案表", &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_Sample04SET_H__29DB24EF_9CFF_4E01_8A62_416ED3BAD531__INCLUDED_)

⌨️ 快捷键说明

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