15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


MFC, DAO connecting

Soren Langkilde Madsen -- slm@dialip.sdn.dk
Saturday, January 11, 1997

Environment : VC++ 4.2-flat, NT 4.0

Problem: How do a user log in to a database using DAO ?

I'm making an application based on DAO. The DAO is used
through MFC's DAO classes.

My problem is that i can't log in as a specific user. This
means that i'll end up as the user "Admin". This must be
the default username in some way.

The code-bit that opens the database.

   CDaoDatabase DbVisasDb;
   ...
   if(!DbVisasDb.IsOpen()) {
     DbVisasDb.Open("O:\\VISAS\\VISASDB.MDB",    // Db name
                    FALSE,                       // Exclusive open
                    TRUE,                        // Read-only
                    _T(";UID=slm;PWD=madsen;")); // connect string
   }

The connect string could mean that you would connect as user "slm"
with the password "madsen"
But no no ... I get in as "Admin" ... The connect string is meant
for DAO access to a ODBC source ... but ...

Do anyone know where i could dig for information ?...

                                          \\  - -  //
		                           (  0 0  ) 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~oOOo-(_)-oOOo~~~~~~~~~~~~~~~~~~~~~~
  Soeren Langkilde Madsen       Job phone          : (+45) 35 26 71 00
  Fagerbo 59, Floeng            Prv phone          : (+45) 46 59 03 78
  2640 Hedehusene               Mobil phone        : (+45) 40 28 30 78
                                GSM-SMS e-mail     : 40283078@sms.tdm.dk
                                Job E-mail         : slm@dialip.sdn.dk
                                Prv E-mail         : slm@dialip.sdn.dk
                                Compagny e-mail    : cad-komp@euroconnect.dk




Klaus Kurzawa -- klausk@hem.passagen.se
Monday, January 13, 1997

[Mini-digest: 2 responses]

Hi Soren,

I looked into the example at CDatabase::Open and I think You have to change
the fourth argument to _T("ODBC;UID=slm;PWD=madsen;")

if (!DbVisasDb.IsOpen()) 
{
    DbVisasDb.Open("O:\\VISAS\\VISASDB.MDB",	// Db name
                   FALSE,                       		// Exclusive open
                   TRUE,                        		// Read-only
                   _T("ODBC;UID=slm;PWD=madsen;"));	// connect string
}

Let me know how if it worked or not!

/Klaus Kurzawa

----------
> From: Soren Langkilde Madsen 
> To: mfc-l@netcom.com
> Subject: MFC, DAO connecting
> Date:  den 11 januari 1997 22:19
> 
> Environment : VC++ 4.2-flat, NT 4.0
> 
> Problem: How do a user log in to a database using DAO ?
> 
> I'm making an application based on DAO. The DAO is used
> through MFC's DAO classes.
> 
> My problem is that i can't log in as a specific user. This
> means that i'll end up as the user "Admin". This must be
> the default username in some way.
> 
> The code-bit that opens the database.
> 
>    CDaoDatabase DbVisasDb;
>    ...
>    if(!DbVisasDb.IsOpen()) {
>      DbVisasDb.Open("O:\\VISAS\\VISASDB.MDB",    // Db name
>                     FALSE,                       // Exclusive open
>                     TRUE,                        // Read-only
>                     _T(";UID=slm;PWD=madsen;")); // connect string
>    }
> 
> The connect string could mean that you would connect as user "slm"
> with the password "madsen"
> But no no ... I get in as "Admin" ... The connect string is meant
> for DAO access to a ODBC source ... but ...
> 
> Do anyone know where i could dig for information ?...
> 
>                                           \\  - -  //
> 		                           (  0 0  ) 
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~oOOo-(_)-oOOo~~~~~~~~~~~~~~~~~~~~~~
>   Soeren Langkilde Madsen       Job phone          : (+45) 35 26 71 00
>   Fagerbo 59, Floeng            Prv phone          : (+45) 46 59 03 78
>   2640 Hedehusene               Mobil phone        : (+45) 40 28 30 78
>                                 GSM-SMS e-mail     : 40283078@sms.tdm.dk
>                                 Job E-mail         : slm@dialip.sdn.dk
>                                 Prv E-mail         : slm@dialip.sdn.dk
>                                 Compagny e-mail    :
cad-komp@euroconnect.dk

-----From: "A.E. Belgium" 

The documentation about the CDaoWorkspace says, in the Security =
paragraph, that
"=A0MFC does not implement the Users and Groups collections in DAO, =
which are used for security control. If you need those aspects of DAO, =
you must program them yourself via direct calls to DAO interfaces. For =
information, see Technical Note 54 under MFC in Books Online.=A0"

Hope this helps.

Yves Mottiaux=20
A.E. Belgium




James P. Kelleghan -- jpk01@tag.acnet.net
Monday, January 13, 1997

Hi Soren,

The lpszConnect string parameter in your Open method call need to be NULL
for DAO acces. The values you used are only valid for ODBC. 

The DAO Workspace is responsible for establishing the connection between
the user and Database. If you don't specify one in the construcion of you
CDaoDatabase object then the default "guest" workspace will be used.

Check the Docs on CDaoDatabase obect and CDaoDatabase::Create() method for
more info.

James

----------
> From: Soren Langkilde Madsen 
> To: mfc-l@netcom.com
> Subject: MFC, DAO connecting
> Date: Saturday, January 11, 1997 3:19 PM
> 
> Environment : VC++ 4.2-flat, NT 4.0
> 
> Problem: How do a user log in to a database using DAO ?
> 
> I'm making an application based on DAO. The DAO is used
> through MFC's DAO classes.
> 
> My problem is that i can't log in as a specific user. This
> means that i'll end up as the user "Admin". This must be
> the default username in some way.
> 
> The code-bit that opens the database.
> 
>    CDaoDatabase DbVisasDb;
>    ...
>    if(!DbVisasDb.IsOpen()) {
>      DbVisasDb.Open("O:\\VISAS\\VISASDB.MDB",    // Db name
>                     FALSE,                       // Exclusive open
>                     TRUE,                        // Read-only
>                     _T(";UID=slm;PWD=madsen;")); // connect string
>    }
> 
> The connect string could mean that you would connect as user "slm"
> with the password "madsen"
> But no no ... I get in as "Admin" ... The connect string is meant
> for DAO access to a ODBC source ... but ...
> 
> Do anyone know where i could dig for information ?...
> 
>                                           \\  - -  //
> 		                           (  0 0  ) 
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~oOOo-(_)-oOOo~~~~~~~~~~~~~~~~~~~~~~
>   Soeren Langkilde Madsen       Job phone          : (+45) 35 26 71 00
>   Fagerbo 59, Floeng            Prv phone          : (+45) 46 59 03 78
>   2640 Hedehusene               Mobil phone        : (+45) 40 28 30 78
>                                 GSM-SMS e-mail     : 40283078@sms.tdm.dk
>                                 Job E-mail         : slm@dialip.sdn.dk
>                                 Prv E-mail         : slm@dialip.sdn.dk
>                                 Compagny e-mail    :
cad-komp@euroconnect.dk





| Вернуться в корень Архива |