Solved

How to open a Jet database with OLE DB

Posted on 2000-02-21
4
895 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

627 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