code:
Code:
class CPasswordsSet : public CCommand<CAccessor<CPassword> >
{
public:
HRESULT Open()
{
CDataSource db;
CSession session;
HRESULT hr;
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_USERID, "Admin");
dbinit.AddProperty(DBPROP_INIT_DATASOURCE, "C:\\Documents and Settings\\Administrator\\桌面\\数据库书籍与程序\\VisualCppdatabase\\visual c++数据库开发经典实例精解\\实例源程序\\Sample5\\数据库\\db2.mdb");
dbinit.AddProperty(DBPROP_INIT_MODE, (long)16);
dbinit.AddProperty(DBPROP_INIT_PROMPT, (short)4);
dbinit.AddProperty(DBPROP_INIT_PROVIDERSTRING, "");
dbinit.AddProperty(DBPROP_INIT_LCID, (long)1033);
//dbinit.AddProperty(DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO, false);
hr = db.OpenWithServiceComponents("Microsoft.Jet.OLEDB.4.0", &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<CPassword> >::Open(session, "SELECT * FROM password", &propset);
if (FAILED(hr))
return hr;
return MoveNext();
}
};
and i find that the problem is on this :" hr = CCommand<CAccessor<CPassword> >::Open(session, "SELECT * FROM password", &propset); "
after this sentence,the "hr" becomes negative,but before this
sentence, the "hr" is zero.
who can give me some suggestion?