Save password for ODBC connection to MS SQL server from MS Access 2007

后端 未结 5 1607
南旧
南旧 2020-12-01 17:26

I am in charge for migrating old Access 2007 project to MS SQL server 2008 Express. The first stage is to move all the data from MS Access database to SQL server while keepi

5条回答
  •  温柔的废话
    2020-12-01 18:10

    The best solution is obviously to use Windows security.

    If that is not suitable, here is a possible alternative trick, exploiting the fact that Access remembers all opened connections until the program is closed:

    1. copy the connect string of one of your tables
    2. create a passthru queries "ptqConnect" and enter any fast SQL statement in it, like SELECT 1
    3. paste the connect string of into the PTQ Connect property, and make sure you add the PWD=something; in it.
    4. in the startup procedure of your app make sure you call that PTQ. Something like DCount("*", "ptqConnect") will do.

    That's it. Since Access remembers opened connections until you close it, even if you close the db, your other tables will now open without any fuss, even if no password is stored in the linked tables Connect string.
    If you don't want to expose the connection string that includes the PWD, you could as well initiate a connection from VBA and hide the code by delivering a MDE or just password protecting the code.

    You can find an explanation of this behaviour here.

提交回复
热议问题