Javascript 使用参数化查询将整数发送到数据库

Javascript 使用参数化查询将整数发送到数据库,javascript,asp-classic,ado,Javascript,Asp Classic,Ado,我无法通过ado参数化查询将stringsvarchar以外的数据发送到存储过程 让我们假设我只是尝试发送一个int参数,并且有一个存储过程接受一个int。当我运行代码时,我得到类型不匹配 如果我将int改为字符串,并且存储过程接受varchar,它就会工作。此外,该存储过程还与用VBScript和PHP编写的其他代码配合使用。所以我猜这不是存储过程 我假设它与.createParameter的线型或长度有关 或者属性行在下面几行。我试过很多不同的组合,但都没有用。 如果需要进一步清理代码,请告

我无法通过ado参数化查询将stringsvarchar以外的数据发送到存储过程

让我们假设我只是尝试发送一个int参数,并且有一个存储过程接受一个int。当我运行代码时,我得到类型不匹配

如果我将int改为字符串,并且存储过程接受varchar,它就会工作。此外,该存储过程还与用VBScript和PHP编写的其他代码配合使用。所以我猜这不是存储过程

我假设它与.createParameter的线型或长度有关 或者属性行在下面几行。我试过很多不同的组合,但都没有用。 如果需要进一步清理代码,请告诉我。谢谢

            command.ActiveConnection = myconn;
            command.CommandText = this.procedure;  
            command.CommandType = 4;
            prmCount = 0;

            //Build Parmeters
            for(var p in this.params){  //<---  I set these params earlier -- they behave as expected

                if(this.params.hasOwnProperty(p)){

                    command.Parameters.Append(

                         command.CreateParameter(
                               "", 
                               this.params[p].type,         // <-- i've tried pretty much every value for the type - 3, 19, 14, 5, ...
                               this.params[p].direction,    // <-- this is the same for all inputs
                               this.params[p].length        // <-- i send null for this value
                         )

                    );

                    //A Fix for Null String values
                    if(this.params[p].value === null || this.params[p].value === ""){
                        command.Parameters(prmCount).Attributes = 64;
                    }

                    //Some examples show adding a `.Attributes` value for some integers
                    //However this didn't help
                    //
                    //if(this.params[p].type === 3){
                        //command.Parameters(prmCount).Attributes = 128;
                    //}

                    command.Parameters(prmCount).Value = this.params[p].value;  //<-- Set the value here
                    prmCount+=1;

                }
            }

            record = command.Execute();

这是ASP Classic中的javascript而不是ASP.net中的javascript吗?然后请更新标签以获得更好的流量。嗯,是的。我想是谁编辑过我的帖子改变了它。因为我也有javascript。你试过parseIntthis.params[p].value吗?@Ali Sheikhpour我之前在构建this.params对象时解析过。但我会核实这只是为了确定。