我有一個訪問2010年,我想在sql 2008服務器上調用sql存儲過程,並將結果返回到記錄集或直接綁定到報表。ms訪問 - 從SQL返回記錄存儲過程
下面的方法返回錯誤「feture在ADP中不可用」或類似的東西 - 它適用於窗體,但不適用於報告。
我該如何去做這件事?
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
您不妨看看http://stackoverflow.com/questions/4184871/adodb-recordset-as-access-report-recordsource – Fionnuala 2012-01-31 21:09:07