访问前端的连接字符串或Server上的安全性都有问题。我赌它是安全的,而且我是个新手。
我已经在SQL Server上针对我的DB设置了我的登录名,并将它分配给了一个对该DB具有执行权限的角色。
我的VBA代码和错误消息一起在下面。本质上,它似乎试图连接到服务器上的另一个db。
Public Sub ExecuteProc(ProcName As String)
On Error GoTo PROC_ERR
Dim cmd As New ADODB.Command
Dim cnn As New ADODB.Connection
Dim stConnect As String
''On Error Resume Next
DoCmd.Hourglass True
stConnect = "Driver={SQL Native Client};Server=MyServer;Database=MyDatabase;UID=MyUser;PWD=MyPWD;"
Debug.Print stConnect
cnn.Open stConnect
With cmd
.ActiveConnection = cnn
.CommandType = adCmdStoredProc
.CommandText = ProcName
.Execute
End With
PROC_EXIT:
On Error Resume Next
DoCmd.Hourglass False
cnn.Close
Set cnn = Nothing
Set cmd = Nothing
Exit Sub
PROC_ERR:
MsgBox Err.Number & vbCrLf & Err.Description
Debug.Print Err.Number & vbCrLf & Err.Description
Resume PROC_EXIT
End Sub错误:
-2147467259
[Microsoft][SQL Native Client][SQL Server]The server principal "MyUser" is not able to access the database "AnotherDatabase" under the current security context.服务器是SQL 2005 SP4,Access应用程序安装在Windows 7计算机上。Windows 7计算机安装了以下驱动程序:
SQL本机客户端2005.90.5000.00
Server 6.01.7601.17514
我已经检查了表面积配置,它是为使用TCP/IP和命名管道的远程连接设置的。还有其他的应用程序连接到服务器上的其他数据库,它们都很好地工作。
我不知道该去哪找。有什么想法吗?
发布于 2014-03-07 06:21:41
检查存储过程本身,以查看它是否正在对其他数据库进行查询。完全可以执行跨数据库查询,然后还需要权限来读取其他数据库。
https://stackoverflow.com/questions/22084392
复制相似问题