📜  用于访问前端的 sql 存储过程 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:31.749000             🧑  作者: Mango

代码示例2
Sub spTest()
Dim qdf As DAO.QueryDef, rst As DAO.Recordset
Dim IdValueToProcess As Long

IdValueToProcess = 2  ' test data

Set qdf = CurrentDb.CreateQueryDef("")
qdf.ReturnsRecords = True
qdf.Connect = "ODBC;DSN=myDb;Trusted_Connection=Yes;"
qdf.SQL = "EXEC dbo.getContact " & IdValueToProcess
Set rst = qdf.OpenRecordset(dbOpenSnapshot)

Debug.Print rst!LastName  ' just to make sure we got a result

rst.Close
Set rst = Nothing
qdf.Close
Set qdf = Nothing
End Sub