Ms access 使用ADO命令对象调用MySql存储函数而不是存储过程
我试图从access中的vba调用这样的存储函数:Ms access 使用ADO命令对象调用MySql存储函数而不是存储过程,ms-access,vba,ado,Ms Access,Vba,Ado,我试图从access中的vba调用这样的存储函数: SELECT my_function(); 如果它是一个存储过程,则如下所示: CALL my_procedure(); 对于存储过程,我可以使用: Dim cmd As Object Set cmd = CreateObject("ADODB.Command") With cmd Set .ActiveConnection = oConn 'ADODB connection created elsewhere .Comm
SELECT my_function();
如果它是一个存储过程,则如下所示:
CALL my_procedure();
对于存储过程,我可以使用:
Dim cmd As Object
Set cmd = CreateObject("ADODB.Command")
With cmd
Set .ActiveConnection = oConn 'ADODB connection created elsewhere
.CommandType = adCmdStoredProc
.CommandText = "my_procedure"
End With
cmd.execute
具体地说,我想知道函数是否有与“adCmdStoredProc”等效的语句?您是否尝试将其作为
SELECT
语句运行
SELECT *
FROM my_function()
“具体而言,我想知道函数是否有“adCmdStoredProc”的等效项?”
但您使用的SQL是一个SELECT,它引用一个函数:
SELECT my_function();
您有7个CommandTypeEnum选项。ADC应该起作用;可能也不知道。我会使用adCmdText,但它并不是函数的“等效”adCmdStoredProc
CommandTypeEnum Constants
Constant Value Description
adCmdFile 256 Evaluate as a previously persisted file
adCmdStoredProc 4 Evaluate as a stored procedure
adCmdTable 2 Have the provider generate a SQL query and return all rows from the specified table
adCmdTableDirect 512 Return all rows from the specified table
adCmdText 1 Evaluate as a textual definition
adCmdUnknown 8 The type of the CommandText parameter is unknown
adCmdUnspecified -1 Default, does not specify how to evaluate
是的,这很有效,但我真的很想知道函数是否有与adCmdStoredProc等效的函数。也许我在这方面不清楚。我不知道函数是否有与adCmdStoredProc等效的函数。我总是使用Select从函数返回。