?? passwordsset.h
字號(hào):
// PasswordsSet.h : interface of the CPasswordsSet class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_PASSWORDSSET_H__54E691E6_DFF2_4BE9_88B3_1754A14759E1__INCLUDED_)
#define AFX_PASSWORDSSET_H__54E691E6_DFF2_4BE9_88B3_1754A14759E1__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CPassword
{
public:
CPassword()
{
memset( (void*)this, 0, sizeof(*this) );
};
//為每個(gè)字段定義對(duì)應(yīng)的數(shù)據(jù)成員
char m_password[11];
char m_userid[16];
BEGIN_COLUMN_MAP(CPassword)
//建立數(shù)據(jù)成員與字段變量的映射
COLUMN_ENTRY_TYPE(2, DBTYPE_STR, m_password)
COLUMN_ENTRY_TYPE(1, DBTYPE_STR, m_userid)
END_COLUMN_MAP()
};
class CPasswordsSet : public CCommand<CAccessor<CPassword> >
{
public:
HRESULT Open()
{
CDataSource db;
CSession session;
HRESULT hr;
//定義打開(kāi)記錄集的選項(xiàng)
CDBPropSet dbinit(DBPROPSET_DBINIT);
dbinit.AddProperty(DBPROP_AUTH_CACHE_AUTHINFO, true);
dbinit.AddProperty(DBPROP_AUTH_ENCRYPT_PASSWORD, false);
dbinit.AddProperty(DBPROP_AUTH_MASK_PASSWORD, false);
dbinit.AddProperty(DBPROP_AUTH_PASSWORD, "");
dbinit.AddProperty(DBPROP_AUTH_PERSIST_ENCRYPTED, false);
dbinit.AddProperty(DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO, false);
dbinit.AddProperty(DBPROP_AUTH_USERID, "Admin");
dbinit.AddProperty(DBPROP_INIT_DATASOURCE, "C:\\VCSample\\數(shù)據(jù)庫(kù)\\passwords.mdb");
dbinit.AddProperty(DBPROP_INIT_MODE, (long)16);
dbinit.AddProperty(DBPROP_INIT_PROMPT, (short)4);
dbinit.AddProperty(DBPROP_INIT_PROVIDERSTRING, ";COUNTRY=0;CP=1252;LANGID=0x0409");
dbinit.AddProperty(DBPROP_INIT_LCID, (long)1033);
hr = db.OpenWithServiceComponents("Microsoft.Jet.OLEDB.3.51", &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 );
//打開(kāi)記錄集
hr = CCommand<CAccessor<CPassword> >::Open(session, "SELECT * FROM password", &propset);
if (FAILED(hr))
return hr;
return MoveNext();//執(zhí)行MoveNext()函數(shù),使第一條記錄成為當(dāng)前記錄
}
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_PASSWORDSSET_H__54E691E6_DFF2_4BE9_88B3_1754A14759E1__INCLUDED_)
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -