Database problems  
Author Message
diabulos





PostPosted: Sun Jun 20 01:46:09 CDT 2004 Top

MFC >> Database problems

Hello

I'm writting a program which uses a password protected access database
, I khow how to connect database while it is not password protected
using ODBC.(I grabed the code from codeproject).

but How can I connect to a password protected access database?

please reply to group(not to my email)
Best regards,

Visual Studio76  
 
 
david7654





PostPosted: Sun Jun 20 01:46:09 CDT 2004 Top

MFC >> Database problems I'm currently using this code for a unicode project:

CString sDriver = _T("MICROSOFT ACCESS DRIVER (*.mdb)");
CString sDsn;
CString sFile;
WCHAR buffer[MAX_PATH];
GetModuleFileName(AfxGetInstanceHandle(), buffer, MAX_PATH);
sFile =(CString)buffer;
sFile = sFile.Left(sFile.ReverseFind('\\'));
sFile += _T("\\db1.mdb");
sDsn.Format(_T("ODBC;DRIVER={%s};DSN='';DBQ=%s"),sDriver,sFile);
database.Open(NULL,false,false,sDsn);

where should I add password?

Best regards



> Hello
>
> I'm writting a program which uses a password protected access database
> , I khow how to connect database while it is not password protected
> using ODBC.(I grabed the code from codeproject).
>
> but How can I connect to a password protected access database?
>
> please reply to group(not to my email)
> Best regards,
 
 
paul





PostPosted: Mon Jun 21 06:45:34 CDT 2004 Top

MFC >> Database problems
> I'm currently using this code for a unicode project:
>
> CString sDriver = _T("MICROSOFT ACCESS DRIVER (*.mdb)");
> CString sDsn;
> CString sFile;
> WCHAR buffer[MAX_PATH];
> GetModuleFileName(AfxGetInstanceHandle(), buffer, MAX_PATH);
> sFile =(CString)buffer;
> sFile = sFile.Left(sFile.ReverseFind('\\'));
> sFile += _T("\\db1.mdb");
> sDsn.Format(_T("ODBC;DRIVER={%s};DSN='';DBQ=%s"),sDriver,sFile);
> database.Open(NULL,false,false,sDsn);
>
> where should I add password?
>

AFAIA, you can add it anywhere in the connection string. It takes the
form "PWD=<password>;" You may need to tell it the user as well
(connection string prefix UID).

Paul.