Ms access ms access-从sql存储过程返回记录
我有一个access 2010,我想调用sql 2008服务器上的sql存储过程,并将结果返回到记录集或直接绑定到报表 下面的方法返回错误“feture not available in ADP”或类似的内容-它可以处理表单,但不能处理报表 我该怎么做呢Ms access ms access-从sql存储过程返回记录,ms-access,adodb,ms-access-2010,Ms Access,Adodb,Ms Access 2010,我有一个access 2010,我想调用sql 2008服务器上的sql存储过程,并将结果返回到记录集或直接绑定到报表 下面的方法返回错误“feture not available in ADP”或类似的内容-它可以处理表单,但不能处理报表 我该怎么做呢 Dim cn As New ADODB.Connection Dim rs As ADODB.Recordset Dim cm As New ADODB.Command 'Use the ADO connection that Access
Dim cn As New ADODB.Connection
Dim rs As ADODB.Recordset
Dim cm As New ADODB.Command
'Use the ADO connection that Access uses
Set cn = CurrentProject.AccessConnection
With cn
.Provider = "Microsoft.Access.OLEDB.10.0"
.Properties("Data Provider").Value = "SQLOLEDB"
.Properties("Data Source").Value = "dsidsw923"
.Properties("Integrated Security").Value = "SSPI"
.Properties("Initial Catalog").Value = "Promotions_Dev_DSI"
.Open
End With
'Create an instance of the ADO Recordset class, and
'set its properties
Set rs = New ADODB.Recordset
With cm
.ActiveConnection = cn
.CommandText = "spCheckProdWkConsist"
.CommandType = adCmdStoredProc
Set rs = .Execute()
End With
'Set the form's Recordset property to the ADO recordset
Set Me.Recordset = rs
Set rs = Nothing
Set cn = Nothing
Set cm = Nothing
考虑创建一个视图来包装存储过程的结果(
exec usp\u which
),然后创建一个链接到新视图的表
此外,您还可以创建一个直通查询(
exec usp\u which
),该查询执行存储过程并直接返回结果。然后只需将报表或表单绑定到查询。您可能希望查看无法从存储过程中选择*的内容。如果您可以提供有帮助的passthrough查询的代码示例,谢谢。好的,那么您可以将exec包装在视图中,或者使用passthrough查询。