David C. Holley wrote:
> This article discusses two methods by which a DSN-less connection can be
> made to SQLServer. http://support.microsoft.com/kb/892490
>
> One uses the CreateTableDef the other uses DAO.RegisterDatabase. Any
> suggestions as to which would be the preferred approach? Any opinions about
> either? I'm inclined to stay awy from the first since it captures user name
> and pwd.
>
>
No different from RegisterDatabase, actually. RegisterDatabase expects a
DSN, which stores the username and passwords in the registry hive
plaintext. Also, I wouldn't really call RegisterDatabase method a
DSN-less connection because it actually creates a new DSN.
If you are concerned about protecting the password, IMHO, the best
policy is to not store the password at all- have the user type in the
password just in the time to execute an ad hoc query. All other objects
(e.g. tabledefs and querydefs)'s Connect property should then contain
only three things: Driver, Server and Database. Access caches the
connection you create and is smart enough to re-use the cached
connection where those three attributes matches.
However, there is a security hole: If the application is allowed to
closing without also quitting Access, it's possible to subsequently open
another .mdb/.accdb while the Access is still open and still have the
full access to the server that original application linked to. For this
reasons, you should ensure that when the last open form closes, this
forces Access to quit and thus close the connection.
AFAIK, this cached connection is not accessible programmically.
HTH.