我是用CDataSource类来访问的;
CDBPropSet设置属性时怎么设置密码呢?
我的数据库文件格式是.mdb的;有名称和正确的口令;但是打不开?
急!急!急!急!急!急!急!急!
---------------------------------------------------------------
?
不是在CDataSource::Open中设置用户、密码之类的吗?
---------------------------------------------------------------
up
---------------------------------------------------------------
up一下
---------------------------------------------------------------
???
---------------------------------------------------------------
CDataSource db;
CSession session;
HRESULT hr;
CDBPropSet dbinit[2];
dbinit[0].SetGUID(DBPROPSET_DBINIT);
//Set Jet OLE DB provider specific properties
dbinit[1].SetGUID(DBPROPSET_JETOLEDB_DBINIT);
dbinit[0].AddProperty(DBPROP_AUTH_CACHE_AUTHINFO, true);
dbinit[0].AddProperty(DBPROP_AUTH_ENCRYPT_PASSWORD, false);
dbinit[0].AddProperty(DBPROP_AUTH_MASK_PASSWORD, false);
dbinit[0].AddProperty(DBPROP_AUTH_PASSWORD, "password1");
dbinit[0].AddProperty(DBPROP_AUTH_USERID, "user1");
dbinit[0].AddProperty(DBPROP_INIT_DATASOURCE, "C:\\test.mdb");
dbinit[0].AddProperty(DBPROP_INIT_MODE, (long)16);
dbinit[0].AddProperty(DBPROP_INIT_PROMPT, (short)4);
dbinit[0].AddProperty(DBPROP_INIT_PROVIDERSTRING, ";COUNTRY=0;CP=1252;LANGID=0x0409");
dbinit[0].AddProperty(DBPROP_INIT_LCID, (long)1033);
dbinit[0].AddProperty(DBPROP_AUTH_PERSIST_SENSITIVE_AUTHINFO, false);
//Database password
dbinit[1].AddProperty(DBPROP_JETOLEDB_DATABASEPASSWORD, "Demo");
//System database
dbinit[1].AddProperty(DBPROP_JETOLEDB_SYSDBPATH, "C:\\winnt\\system32\\system.mdw");
hr = db.OpenWithServiceComponents("Microsoft.Jet.OLEDB.4.0", dbinit,2);
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 );