传递查询成功连接后忽略不正确的密码
Pass-through Query Ignores incorrect passwords after a successful connection
我有使用连接字符串和密码创建直通查询的脚本。它适用于第一次连接尝试:失败,直到用户输入正确的密码。如果连接串丢失或者用户出于任何原因需要租用它,无论通过连接串传递什么密码都会成功。
我试过创建命名的 queryDefs 并删除它们,唯一的和非唯一的。如果这是必须的方式,我会使用它,但我不喜欢不了解正在发生的事情,所以如果有人有任何洞察力,那就太好了。谢谢!
Dim db As DAO.Database, qDef As QueryDef, rst As DAO.Recordset
Set db = CurrentDb
Set qDef = db.CreateQueryDef(vbNullString)
With qDef
.Connect = connStr
.sql = sql
.ReturnsRecords = True
Set rst = .OpenRecordset(dbOpenSnapshot, dbSQLPassThrough)
End With
If readAll Then
With rst
If Not .EOF And Not .BOF Then
.MoveLast
.MoveFirst
End If
End With
End If
Set PassThroughRecordset = rst
这是设计使然,只要 Access 运行,与 user/password 的连接就会被缓存,而 server/db 保持不变。
查看此处和链接 blog post:
Save password for ODBC connection to MS SQL server from MS Access 2007
How to avoid prompting for user id and password in MSAccess 2003
我有使用连接字符串和密码创建直通查询的脚本。它适用于第一次连接尝试:失败,直到用户输入正确的密码。如果连接串丢失或者用户出于任何原因需要租用它,无论通过连接串传递什么密码都会成功。
我试过创建命名的 queryDefs 并删除它们,唯一的和非唯一的。如果这是必须的方式,我会使用它,但我不喜欢不了解正在发生的事情,所以如果有人有任何洞察力,那就太好了。谢谢!
Dim db As DAO.Database, qDef As QueryDef, rst As DAO.Recordset
Set db = CurrentDb
Set qDef = db.CreateQueryDef(vbNullString)
With qDef
.Connect = connStr
.sql = sql
.ReturnsRecords = True
Set rst = .OpenRecordset(dbOpenSnapshot, dbSQLPassThrough)
End With
If readAll Then
With rst
If Not .EOF And Not .BOF Then
.MoveLast
.MoveFirst
End If
End With
End If
Set PassThroughRecordset = rst
这是设计使然,只要 Access 运行,与 user/password 的连接就会被缓存,而 server/db 保持不变。
查看此处和链接 blog post:
Save password for ODBC connection to MS SQL server from MS Access 2007
How to avoid prompting for user id and password in MSAccess 2003