调用 Sub 时不能使用括号 [英] Cannot use parentheses when calling a Sub
问题描述
我有一个经典 ASP 页面,其中包含以下代码来尝试参数化查询;
I have a Classic ASP page that contains the following code to attempt a parametised query;
<%
Set cmdEmail = Server.CreateObject("ADODB.Command")
Set rsEmail = Server.CreateObject("ADODB.Recordset")
cmdEmail.CommandText = "SELECT * FROM VWTenantPropertiesResults WHERE ContentID = ?"
cmdEmail.CommandType = 1
cmdEmail.ActiveConnection = MM_dbconn_STRING
cmdEmail.Parameters.Append
cmdEmail.CreateParameter("@ContentID", 3, 1, , request.Form("ContentID"))
rsEmail.Open cmdEmail
%>
但是页面现在报如下错误;
However, the page is now reporting the following error;
调用 Sub 时不能使用括号/welcome/default2.asp,第 436 行cmdEmail.CreateParameter("@ContentID", 3, 1, , request.Form(ContentID))-----------------------------------------------------------------------^
Cannot use parentheses when calling a Sub /welcome/default2.asp, line 436 cmdEmail.CreateParameter("@ContentID", 3, 1, , request.Form(ContentID)) -----------------------------------------------------------------------^
这是 ASP 的一些错误,还是我需要更改尝试参数化查询的方式?
Is this some bug with ASP or do I need to change how I attempt parametised queries?
谢谢.
推荐答案
你是不是试着去掉那些括号?
Did you tried just to remove those parenthesis?
cmdEmail.CreateParameter "@ContentID", 3, 1, , Request.Form("ContentID")
据我所知,当你调用一个函数并且不使用它的返回值时,总是会发生这种情况.
As far as I remember, that always happens when you call a function and doesn't use its return value.
更新:似乎真正的问题是换行:
UPDATE: Seems the real problem is the line break:
cmdEmail.Parameters.Append _ '' note this "_" character
cmdEmail.CreateParameter("@ContentID", 3, 1, , Request.Form("ContentID"))
这篇关于调用 Sub 时不能使用括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!