UID/PWD ignored in C++ DAO

UID/PWD ignored in C++ DAO

Post by Rich B » Sun, 13 Oct 2002 06:41:37



Greetings!

I am trying to open an ODBC connection using DAO.
In VB, the connections string "ODBC;dsn=mydsn;uid=xxx;pwd=yyy" works
just fine.  But in DAO, the uid and pwd are ignored, and the driver opens
a login dialog.

How can I prevent this?

In the example below, the uid and pwd allow the database open to work, but
they
are not remembered, and the recordset open shows the login dialog.  If I
don't
specify a uid/pwd in either the connect string or in the registry, then I
get TWO login
dialogs.

My code looks like:

   pdbJS = new CDaoDatabase();
   pdbJS->Open("", FALSE, FALSE,"ODBC;DSN=mydsn;UID=user;PWD=pw");
   prsJS = new CDaoRecordset(pdbJS);
   prsJS->Open(dbOpenDynaset, "SELECT * from PROFIL", dbReadOnly);
   prsJS->MoveFirst();

I had assumed this was an ODBC driver problem, but it works perfectly in VB.

Thanks in advance!

Rich

 
 
 

UID/PWD ignored in C++ DAO

Post by Rich B » Sun, 13 Oct 2002 07:03:42


Somewhat ambiguous:  I am trying to use DAO in VC++.


Quote:> Greetings!

> I am trying to open an ODBC connection using DAO.
> In VB, the connections string "ODBC;dsn=mydsn;uid=xxx;pwd=yyy" works
> just fine.  But in DAO, the uid and pwd are ignored, and the driver opens
> a login dialog.

> How can I prevent this?

> In the example below, the uid and pwd allow the database open to work, but
> they
> are not remembered, and the recordset open shows the login dialog.  If I
> don't
> specify a uid/pwd in either the connect string or in the registry, then I
> get TWO login
> dialogs.

> My code looks like:

>    pdbJS = new CDaoDatabase();
>    pdbJS->Open("", FALSE, FALSE,"ODBC;DSN=mydsn;UID=user;PWD=pw");
>    prsJS = new CDaoRecordset(pdbJS);
>    prsJS->Open(dbOpenDynaset, "SELECT * from PROFIL", dbReadOnly);
>    prsJS->MoveFirst();

> I had assumed this was an ODBC driver problem, but it works perfectly in
VB.

> Thanks in advance!

> Rich


 
 
 

UID/PWD ignored in C++ DAO

Post by Rich B » Wed, 16 Oct 2002 04:38:01


New update:

Modifying code to use CDatabase and CRecordset (OLE DB) works fine.
Is DAO no longer supported?  Even the latest Platform SDK did not
fix the problem using DAO.

Other than curousity, my issue is resolved.

 
 
 

1. DAO caches UID and PWD for a given ODBC connection

I quote from DAO help:
        "Jet caches the user ID and password along with the connection,
so that you're not repeatedly prompted. This means that if your
application needs to log on to the server with a different user ID and
password, you will be unable to do so unless you force the closure of
any existing connections."

In this moment I make a client-server based application. Server receive
request from clients and make a mdb database beginning from an ODBC
connection to SQL Server. Therefore, I must log into SQL Server as user
who send current request.

How can I delete cached user and password (or disable this feature) for
a given DSN?

Thanks,
Horatiu Minca

2. shared pool / View v$sgastat

3. How to open secured database through ODBC without sending UID and PWD in connection string

4. Oracle DBA Wanted

5. Accessing .mdb with UID and PWD?

6. Search for CHAR(13) with the LIKE operator

7. Open database without UID and PWD!!

8. Help: Passing a recordset to a function

9. ODBC login to Sybase without UID, PWD

10. How To Create Database, UID, PWD

11. Newbie: What's my uid and pwd for my asp conn-string

12. Saving UID and PWD for ODBC connection

13. SQL Server DNS UID & PWD