简体   繁体   English

参数数量错误或属性分配无效:“ CommandText”

[英]Wrong number of arguments or invalid property assignment: 'CommandText'

I have the following code in a Classic ASP website that I have to update the SQL statements and for some reason I keep getting the error Wrong number of argument or invalid property assignment 'Command Text. 我在Classic ASP网站中有以下代码,我必须更新SQL语句,并且由于某些原因,我不断收到错误的错误参数数目或无效的属性分配'命令文本。 I have tried changing the createParameter to the first line of code but that does not work. 我试过将createParameter更改为代码的第一行,但这不起作用。 So I changed it to the line in the second CreateParameter but neither one works. 所以我将其更改为第二个CreateParameter中的行,但没有一个起作用。 Any help would be greatly appreciated. 任何帮助将不胜感激。

cmd.Parameters.Append cmd.CreateParameter("@parm1",adSingle,adParamInput,,tailno)  


set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = tadsdb
cmd.CommandText "INSERT INTO TAR_DATA (TN_ID) VALUES (?)"
cmd.CommandType = adCmdText
cmd.Parameters.Append cmd.CreateParameter("@parm1",3,1,,tailno)
cmd.Execute

cmd.CommandText doesn't take an argument but requires an assignment. cmd.CommandText不带参数,但需要赋值。

To resolve your problem you should add the '=' operator between the CommandText and your given query. 若要解决您的问题,应在CommandText和给定查询之间添加'='运算符。

This line: 这行:

cmd.CommandText "INSERT INTO TAR_DATA (TN_ID) VALUES (?)"

Should become: 应成为:

cmd.CommandText = "INSERT INTO TAR_DATA (TN_ID) VALUES (?)"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM