Solved

How to open a Jet database with OLE DB

Posted on 2000-02-21
4
878 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 23

Accepted Solution

by:
naveenkohli earned 100 total points
ID: 2544674
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
ID: 2544795
Thank you.
0
 

Author Comment

by:hshliang
ID: 2544908
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
ID: 2573725
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
not able to insert into temp table 68 178
zeroMAx challenge 20 135
sumHeights  challenge 17 83
Bartender label printing - switch on and off graphics 3 94
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. …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

734 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