hshliang
asked on
How to open a Jet database with OLE DB
I am learning to do OLE DB. I manage to open the CDataSource with the method Open(). But when I try to open an Access database that has a database password, it fails. I look up the Help and found a 'prop' call DBPROP_JETOLEDB_DATABASEPA SSWORD which should be the property for the initial string. However, when I compile, this constant is NOT defined.
Q: 1, Is this the way ( to use DBPROPSET) to open a password protected Jet (Access) database?
2, Where do I find the defination of the constant DBPROP_JETOLEDB_DATABASEPA SSWORD? it is not mentioned in the help.
Thanks
Q: 1, Is this the way ( to use DBPROPSET) to open a password protected Jet (Access) database?
2, Where do I find the defination of the constant DBPROP_JETOLEDB_DATABASEPA
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Dear Naveenkohli,
I just find out that CDataSource::Open(Clsid,&p ropset) only takes one property set and to supply the name of the database, it takes DBPROPSET_DBINIT using DBPROP_INIT_DATASOURCE as property.
How do I add another propertyset (i.e. DBPROPSET_JETOLEDB_DBINIT) with the property of DBPROP_JETOLEDB_DATABASEPA SSWORD??
Please help.
Or is there an other way to open the database that is password protected?
I just find out that CDataSource::Open(Clsid,&p
How do I add another propertyset (i.e. DBPROPSET_JETOLEDB_DBINIT)
Please help.
Or is there an other way to open the database that is password protected?
ASKER
I found the answer. In fact the Open function can take an array of CPropertyset with a number of element in the array following it.
See Atldbcli.h , look under CDataSource Open functon
e.g.
CPropertyset ppset[2]
ppset[0].SetGUID(...)
ppset[0].AddProperty(..).. .
ppset[1].SetGUID(..)
ppset[1].SetPrperty(..)...
m_datasource.Open(m_clsid, ppset, 2) will work.
See Atldbcli.h , look under CDataSource Open functon
e.g.
CPropertyset ppset[2]
ppset[0].SetGUID(...)
ppset[0].AddProperty(..)..
ppset[1].SetGUID(..)
ppset[1].SetPrperty(..)...
m_datasource.Open(m_clsid,
ASKER