Solved

How to open a Jet database with OLE DB

Posted on 2000-02-21
4
806 Views
Last Modified: 2013-11-20
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_DATABASEPASSWORD 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_DATABASEPASSWORD? it is not mentioned in the help.
Thanks
0
Comment
Question by:hshliang
  • 3
4 Comments
 
LVL 23

Accepted Solution

by:
naveenkohli earned 100 total points
Comment Utility
The header file for this property definition is missing. Look at the knowledge base article Q192328. You can download the header file from microsoft site.


File Name : MsJetOleDb.h

//=======================================================================
// Microsoft JET OLEDB Provider
//
// Microsoft Confidential.  Copyright (c) 1995-7 Microsoft Corporation.
//
// Component: Microsoft JET Database Engine OLEDB Layer
//
// File: MSJETOLEDB.H
//
// File Comments: This file contains the GUIDS necessary to load the
//                          Microsoft JET OLEDB Layer for the JET 3.51 database
//                          Engine.
//
//=======================================================================

#ifndef MSJETOLEDB_H
#define MSJETOLEDB_H

// OLE DB Provider
const GUID CLSID_JETOLEDB_3_51                  = {0xdee35060,0x506b,0x11cf,{0xb1,0xaa,0x00,0xaa,0x00,0xb8,0xde,0x95}};

const GUID DBPROPSET_JETOLEDB_ROWSET      = {0xa69de420,0x0025,0x11d0,{0xbc,0x9c,0x00,0xc0,0x4f,0xd7,0x05,0xc2}};
const GUID DBPROPSET_JETOLEDB_SESSION   = {0xb20f6c12,0x9b2a,0x11d0,{0x9e,0xbd,0x00,0xc0,0x4f,0xc2,0xc2,0xe0}};
const GUID DBPROPSET_JETOLEDB_DBINIT      = {0x82cf8156,0x9b40,0x11d0,{0x9e,0xbd,0x00,0xc0,0x4f,0xc2,0xc2,0xe0}};
const GUID DBPROPSET_JETOLEDB_TABLE            = {0xe64cc5fc,0x9ff2,0x11d0,{0x9e,0xbd,0x00,0xc0,0x4f,0xc2,0xc2,0xe0}};

// PROPIDs for DBPROPSET_JETOLEDB_ROWSET:
#define DBPROP_JETOLEDB_ODBCPASSTHROUGH                              0xFD
#define DBPROP_JETOLEDB_ODBCPASSTHROUGHCONNECTSTRING      0xF2
#define DBPROP_JETOLEDB_BULKPARTIAL                                    0xEF
#define DBPROP_JETOLEDB_3_5_ENABLEIRowsetIndex                  0x101      // 3.5 ONLY - enable IRowsetIndex interface for Seek

// PROPIDs for DBPROPSET_JETOLEDB_SESSION:
#define DBPROP_JETOLEDB_RECYCLELONGVALUEPAGES                  0xF9

// PROPIDs for DBPROPSET_JETOLEDB_DBINIT:
#define DBPROP_JETOLEDB_REGPATH                                          0xFB
#define DBPROP_JETOLEDB_SYSDBPATH                                    0xFA      // Full Path to System Database
#define DBPROP_JETOLEDB_DATABASEPASSWORD                        0x100      // Password for Database
#define DBPROP_JETOLEDB_GLOBALBULKPARTIAL                        0x109      // Database Default Partial/No Partial Behavior

// PROPIDs for DBPROPSET_JETOLEDB_TABLE:
#define DBPROP_JETOLEDB_LINK                                          0xF7
#define DBPROP_JETOLEDB_LINKEXCLUSIVE                              0xF6
#define DBPROP_JETOLEDB_LINKDATASOURCE                              0xF5
#define DBPROP_JETOLEDB_LINKPROVIDERSTRING                        0xF4
#define DBPROP_JETOLEDB_LINKREMOTETABLE                              0xF3
#define DBPROP_JETOLEDB_LINKCACHE_AUTHINFO                        0xF0

// DBPROP_JETOLEDB_GLOBALBULKPARTIAL/DBPROP_JETOLEDB_BULKPARTIAL Enumeration Values
#define DBPROPVAL_BP_DEFAULT                                          0x00      // Default (only valid for DBPROP_JETOLEDB_BULKPARTIAL)
#define DBPROPVAL_BP_PARTIAL                                          0x01      // Use partial updates (like Access)
#define DBPROPVAL_BP_NOPARTIAL                                          0x02      // Use No Partial Behavior (all or nothing)

#endif //MSJETOLEDB_H
0
 

Author Comment

by:hshliang
Comment Utility
Thank you.
0
 

Author Comment

by:hshliang
Comment Utility
Dear Naveenkohli,
I just find out that CDataSource::Open(Clsid,&propset) 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_DATABASEPASSWORD??

Please help.
Or is there an other way to open the database that is password protected?

0
 

Author Comment

by:hshliang
Comment Utility
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.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now