Use function call in passthrough query?

后端 未结 1 1259
不知归路
不知归路 2021-01-22 13:26

I have a passthrough query in an Access 2010 application, which I\'m using to call a stored procedure on a SQL Server backend. The stored procedure takes a parameter that I need

相关标签:
1条回答
  • 2021-01-22 14:15

    You can use this code:

    With CurrentDb.QueryDefs("MyPass")
      .SQL = "exec spMyProc '" & getUserName() & "'"
      .Execute
    End With
    

    Because getUserName() is a local VBA function, then you need to pre-evaluate the actual string sent to SQL server. As above shows using a saved pass-though is "handy" since you don't have to deal with connection strings etc.

    0 讨论(0)
提交回复
热议问题