0

コマンドオブジェクトで問題が発生し、構築された文字列からパラメータ化されたクエリにいくつかのコードを変換中です。

if (session("pafWebService") = true) then

Dim adoCMD 
Dim adoRS 
Dim strSQL 
Dim lRecordsAffected 

strSQL =  "insert into job values  (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,)" 

Set adoCMD = Server.CreateObject("ADODB.Command")
With adoCMD
.ActiveConnection = conn
.CommandText = strSQL
.CommandType = adCmdText
.parameters.Append .CreateParameter("account", adVarChar, adParamInput, 16 , cCustcode)
.parameters.Append .CreateParameter("reference", adVarChar, adParamInput, 40 , cReference)
.parameters.Append .CreateParameter("priority", adVarChar, adParamInput, 3 , cPriority)
.parameters.Append .CreateParameter("colldate", adVarChar, adParamInput, 8 , cCollDate)
.parameters.Append .CreateParameter("deldate", adVarChar, adParamInput, 8 , cDelDate)
.parameters.Append .CreateParameter("onby", adInterger, adParamInput, 4 , nOnby)
.parameters.Append .CreateParameter("timestart", adVarChar, adParamInput, 4 , cTimestart)
.parameters.Append .CreateParameter("timeend", adVarChar, adParamInput, 4 , cTimeend)
.parameters.Append .CreateParameter("delname", adVarChar, adParamInput, 40 , cDelname)
.parameters.Append .CreateParameter("deladd1", adVarChar, adParamInput, 40 , cAdd1)
.parameters.Append .CreateParameter("deladd2", adVarChar, adParamInput, 40 , cAdd2)
.parameters.Append .CreateParameter("deladd3", adVarChar, adParamInput, 40 , cAdd3)
.parameters.Append .CreateParameter("deltown", adVarChar, adParamInput, 40 , cAdd4)
.parameters.Append .CreateParameter("delcounty", adVarChar, adParamInput, 40 , cAdd5)
.parameters.Append .CreateParameter("delpostcode", adVarChar, adParamInput, 10 , cPostcode)
.parameters.Append .CreateParameter("goods", adVarChar, adParamInput, 40 , cGoods)
.parameters.Append .CreateParameter("wgt", adInteger, adParamInput, 4 , nWgt)
.parameters.Append .CreateParameter("qty", adInteger, adParamInput, 4 , nQty)
.parameters.Append .CreateParameter("plt", adInteger, adParamInput, 4 , nPlt)
.parameters.Append .CreateParameter("vol", adInteger, adParamInput, 4 , nVol)
.parameters.Append .CreateParameter("haz", adInteger, adParamInput, 4 , nHaz)
.parameters.Append .CreateParameter("adr", adVarChar, adParamInput, 10 , cadr)
.parameters.Append .CreateParameter("adrpack", adVarchar, adParamInput, 10 , cAdrpack)
.parameters.Append .CreateParameter("taillift", adInteger, adParamInput, 4 , nTl)
.parameters.Append .CreateParameter("rigid", adInteger, adParamInput, 4 , nRi)
.parameters.Append .CreateParameter("ringforbook", adInteger, adParamInput, 4 , nBook)
.parameters.Append .CreateParameter("notes", adVarChar, adParamInput, 250 , cNotes)
.parameters.Append .CreateParameter("phoneno", adVarChar, adParamInput, 30 , cPhoneNo)
.parameters.Append .CreateParameter("userid", adInteger, adParamInput, 4 , session("userid"))
.parameters.Append .CreateParameter("confirmed", adInteger, adParamInput, 4 ,0)
.parameters.Append .CreateParameter("processed", adInteger, adParamInput, 4 ,0)
.parameters.Append .CreateParameter("adrname", adVarchar, adParamInput, 30 ,cAdrname)
.parameters.Append .CreateParameter("adrchem", adVarchar, adParamInput, 10 ,cAdrchem)
.parameters.Append .CreateParameter("timestartc", adVarchar, adParamInput, 4 ,ctimestartcol)
.parameters.Append .CreateParameter("timeendc", adVarchar, adParamInput, 4 ,ctimeendcol)
.parameters.Append .CreateParameter("confno", adInteger, adParamInput, 4 ,0)
.parameters.Append .CreateParameter("jobno", adInteger, adParamInput, 4 ,0)
.parameters.Append .CreateParameter("fplt", adInteger, adParamInput, 4 , nfPlt)
.parameters.Append .CreateParameter("hplt", adInteger, adParamInput, 4 , nhPlt)
.parameters.Append .CreateParameter("qplt", adInteger, adParamInput, 4 , nqPlt)
.parameters.Append .CreateParameter("coll1", adVarChar, adParamInput, 30 ,cColl1)
.parameters.Append .CreateParameter("coll2", adVarChar, adParamInput, 30 ,cColl2)
.parameters.Append .CreateParameter("coll3", adVarChar, adParamInput, 30 ,cColl3)
.parameters.Append .CreateParameter("coll4", adVarChar, adParamInput, 30 ,cColl4)
.parameters.Append .CreateParameter("coll5", adVarChar, adParamInput, 30 ,cColl5)
.parameters.Append .CreateParameter("collp", adVarChar, adParamInput, 30 ,cCollp)
.parameters.Append .CreateParameter("colname", adVarChar, adParamInput, 30 ,cColname)
.parameters.Append .CreateParameter("printed", adBoolean, adParamInput, 1 ,false)
.parameters.Append .CreateParameter("cheps", adInteger, adParamInput, 4 ,nCheps)
.parameters.Append .CreateParameter("countryd", adVarChar, adParamInput, 30 ,ccountryd)
.parameters.Append .CreateParameter("countryc", adVarChar, adParamInput, 30 ,ccountryc)
.parameters.Append .CreateParameter("uniqueid", adVarChar, adParamInput, 30 ,cUniqueId)
.parameters.Append .CreateParameter("co2", adInteger, adParamInput, 10 , request.form("cC02"))
.parameters.Append .CreateParameter("carbon", adInteger, adParamInput, 10 , request.form("cCarbon"))
.parameters.Append .CreateParameter("am", adInteger, adParamInput, 4 ,nAM)
.parameters.Append .CreateParameter("pm", adInteger, adParamInput, 4 ,nPM)
.parameters.Append .CreateParameter("instructs", adVarChar, adParamInput, 50 ,cSpecialInstruct)
.parameters.Append .CreateParameter("quote", adVarChar, adParamInput, 59 , trim(cQuoteId))
.parameters.Append .CreateParameter("validdel", adBoolean, adParamInput, 1 , lValidDel)
.parameters.Append .CreateParameter("validcol", adBoolean, adParamInput, 1 , lValidcol)
Set adoRS = .Execute(lRecordsAffected)

  end with  

エラー メッセージ: ADODB.Command エラー '800a0bb9'

引数の型が間違っているか、許容範囲外であるか、互いに競合しています。(行 .CommandType = adCmdText を指している)

4

1 に答える 1

0

これは、値が空の場合に発生します (vbscript データ型)-

たとえば、整数値が確実に NULL であり、空でないことを確認する必要があります... (または 0,1,2...)

次のように、vbscript 値を正しいデータ型に「解析」する関数を作成できます。

function parse(value, alternative)
    dim val
    val = trim(value & "")
    parse = alternative
    if val = "" then exit function
    on error resume next
    select case varType(parse)
        case 2, 3 'integer, long
            parse = cLng(val)
        case 4, 5 'single, double
            parse = cdbl(val)
        case 6  'currency
            parse = ccur(val)
        case 7 'date
            parse = cDate(val)
        case 11 'bool
            parse = cBool(val)
        case 8 'string
            parse = value & ""
        case else
            on error goto 0
            err.raise 1024, "parse(value, alternative)", "Type is not supported. val:" & value & " alt:" & alternative)
    end select
    on error goto 0
end function

' call of parse function:
cCustcode = parse(cCustcode, "")
'or for an integer:
nWgt = parse(nWgt, 0)
于 2013-01-09T14:29:30.300 に答える