📄 record.h
字号:
// Record.H : Declaration of the CRecord class
#ifndef __RECORD_H_
#define __RECORD_H_
class CRecordAccessor
{
public:
LONG m_ID; TCHAR m_column0[51]; TCHAR m_column1[51]; TCHAR m_column2[51]; TCHAR m_Email[51]; TCHAR m_column3[1024];
BEGIN_COLUMN_MAP(CRecordAccessor)
COLUMN_ENTRY(1, m_ID) COLUMN_ENTRY(2, m_column0) COLUMN_ENTRY(3, m_column1) COLUMN_ENTRY(4, m_column2) COLUMN_ENTRY(5, m_Email) COLUMN_ENTRY(6, m_column3)END_COLUMN_MAP()
DEFINE_COMMAND(CRecordAccessor, _T(" \ SELECT \ ID, \ 姓名, \ 部门, \ 电话, \ `E-mail`, \ 备注 \ FROM 员工档案表"))
// You may wish to call this function if you are inserting a record and wish to
// initialize all the fields, if you are not going to explicitly set all of them.
void ClearRecord()
{
memset(this, 0, sizeof(*this));
}
};
class CRecord : public CCommand<CAccessor<CRecordAccessor> >
{
public:
HRESULT Open()
{
HRESULT hr;
hr = OpenDataSource();
if (FAILED(hr))
return hr;
return OpenRowset();
}
HRESULT OpenDataSource()
{
HRESULT hr;
CDataSource db;
CDBPropSet dbinit(DBPROPSET_DBINIT);
dbinit.AddProperty(DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO, false); dbinit.AddProperty(DBPROP_INIT_DATASOURCE, OLESTR("演示数据库")); dbinit.AddProperty(DBPROP_INIT_PROMPT, (short)4); dbinit.AddProperty(DBPROP_INIT_LCID, (long)2052); hr = db.Open(_T("MSDASQL"), &dbinit);
if (FAILED(hr))
return hr;
return m_session.Open(db);
}
HRESULT OpenRowset()
{
// Set properties for open
CDBPropSet propset(DBPROPSET_ROWSET);
propset.AddProperty(DBPROP_IRowsetChange, true);
propset.AddProperty(DBPROP_UPDATABILITY, DBPROPVAL_UP_CHANGE | DBPROPVAL_UP_INSERT | DBPROPVAL_UP_DELETE);
return CCommand<CAccessor<CRecordAccessor> >::Open(m_session, NULL, &propset);
}
CSession m_session;
};
#endif // __RECORD_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -