Open a password-protected Access database 
Author Message
 Open a password-protected Access database

I am trying to open a password-protected Access 95 database using DAO
3.5 from VC++ 5.0. I have tried passing the password in the Connect
parameter of OpenDatabase() in various ways without success. I always
get back DAO error 3031: "Not a valid password." Any suggestions would
be greatly appreciated.

Mike Draganza



Fri, 02 Mar 2001 03:00:00 GMT  
 Open a password-protected Access database
Hi Michael,

If memory serves me you need to use DAO 2.5(3.0) to have modify access to an
Access 95 database.  In any event, the syntax I've always used is:

CDaoDatabase db( &m_daoWrkSpc );
CString strDatabase= _T("MyData.mdb");
CString strConnect= _T(";PWD=MyPassword");
try
{
    db.Open( strDatabase, FALSE, FALSE, strConnect );

Quote:
}

catch( CDaoException* e )
{
    e->ReportError( MB_ICONSTOP| MB_OK );
    e->Delete();
    return( FALSE );
Quote:
}

catch( CMemoryException* e )
{
    e->ReportError( MB_ICONSTOP| MB_OK );
    e->Delete();
    return( FALSE );

Quote:
}

HTH
--
=================
Frank Hickman
Computers Plus


=================



Fri, 02 Mar 2001 03:00:00 GMT  
 Open a password-protected Access database
How do you supply the User Parameter in the Connect string?



Quote:
> Hi Michael,

> If memory serves me you need to use DAO 2.5(3.0) to have modify access to
an
> Access 95 database.  In any event, the syntax I've always used is:

> CDaoDatabase db( &m_daoWrkSpc );
> CString strDatabase= _T("MyData.mdb");
> CString strConnect= _T(";PWD=MyPassword");
> try
> {
>     db.Open( strDatabase, FALSE, FALSE, strConnect );
> }
> catch( CDaoException* e )
> {
>     e->ReportError( MB_ICONSTOP| MB_OK );
>     e->Delete();
>     return( FALSE );
> }
> catch( CMemoryException* e )
> {
>     e->ReportError( MB_ICONSTOP| MB_OK );
>     e->Delete();
>     return( FALSE );
> }

> HTH
> --
> =================
> Frank Hickman
> Computers Plus


> =================



Wed, 07 Mar 2001 03:00:00 GMT  
 Open a password-protected Access database
Hi Michael,

Okay, first let me find out which password your talking about.  There are
two different types of passwords the Access engine supports.

1)    Database Password:  This password is simple used to encrypt the
database.  This is the password that is supplied in the "connect" string.
This is the example I gave you.

CDaoDatabase db( &m_daoWrkSpc );
CString strDatabase= _T("MyData.mdb");
CString strConnect= _T(";PWD=MyPassword");
try
{
    db.Open( strDatabase, FALSE, FALSE, strConnect );

Quote:
}

catch( CDaoException* e )
{
    e->ReportError( MB_ICONSTOP| MB_OK );
    e->Delete();
    return( FALSE );
Quote:
}

catch( CMemoryException* e )
{
    e->ReportError( MB_ICONSTOP| MB_OK );
    e->Delete();
    return( FALSE );

Quote:
}

2)    Username/Password:  This type is used for user authentication.  You
supply this when you create the workspace object.  If you use a database
class or any class that uses the database class without creating a workspace
object you'll get a "default" workspace object that will always use the
username "Admin" with a blank password.  This one is only slightly more
involved.

CDaoWorkspace m_daoWrkSpc;
// Set the registry path to the Jet configuration I'm using (DAOv3.5)
// This tells jet to use my user workspace database for user authorization.
m_daoWrkSpc.SetIniPath( _T("HKEY_LOCAL_MACHINE\\SOFTWARE\\NobleSoft\\Monitor
\\Jet 3.5") );
// These are just defaults if you don't specify them when creating the
// workspace object.
m_daoWrkSpc.SetDefaultUser( _T("MyLogin") );
m_daoWrkSpc.SetDefaultPassword( _T("MyPassword") );

try
{
    // Create the DAO workspace.
    m_daoWrkSpc.Create( _T("NSMonitor"), _T("OtherUser"), _T("OtherPW") );
    // Allocate memory for database object and use just created workspace.
    m_pdaoDb= new CDaoDatabase( &m_daoWrkSpc );
    // Open the database.
    m_pdaoDb->Open( _T("MyData.mdb") );

Quote:
}

catch( CDaoException* e )
{
    e->ReportError( MB_ICONSTOP| MB_OK );
    e->Delete();
    return( FALSE );
Quote:
}

catch( CMemoryException* e )
{
    e->ReportError( MB_ICONSTOP| MB_OK );
    e->Delete();
    return( FALSE );

Quote:
}

p.s.  If you send me email please include your REAL reply address :-)

HTH
--
=================
Frank Hickman
Computers Plus


=================



Wed, 07 Mar 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Open a password protected DataBase

2. open password protected DAO Database

3. Open a password protected Database

4. Error compacting a password-protected Access database

5. SQLConfigDataSource and password protected ACCESS database

6. Password protected Access Database

7. Using CDaoDatabase to Open a Password Protected Access DB

8. Password Protected DataBase

9. Password protected DataBase

10. open a password-protected-sql-database

11. How to compact a password protected database with Visual C++ using ODBC

12. DAO password protected database and class wizard

 

 
Powered by phpBB® Forum Software