所以...我在一个函数中有以下内容,每当它被调用时......我得到一个类型错误
Microsoft VBScript runtime error '800a000d'
类型不匹配:' var'
dim conn, cmd, rs
set conn = GetConnection
''' Set the SQL based on request type '''
If isSubscriber = true Then
execSQL = "select stuff from dbo.stuff WHERE field1 = 12" & _
" AND email= @ParameterPwd" & _
" AND password= @ParameterPwd" & _
" AND EndDate >= GETDATE() "
Else
execSQL = "select stuff from dbo.stuff2 WHERE field1 = 12" & _
" AND email= @ParameterPwd" & _
" AND password= @ParameterPwd" & _
" AND EndDate >= GETDATE() "
End If
Set cmd = Server.CreateObject("ADODB.Command")
''' Create the command with the appropriate SQL and params '''
With cmd
.activeconnection=conn
.commandtext= execSQL
'Create the parameter (name,type,direction,size,value)
.Parameters.Append .CreateParameter("@ParameterEmail", email)
.Parameters.Append .CreateParameter("@ParameterPwd", pwd)
End With
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open cmd, conn
' Disconnect Recordset '
Set rs.ActiveConnection = Nothing
set GetRecordSetSafeUser = rs
错误发生在以下行:
.Parameters.Append .CreateParameter("@ParameterEmail", email)
将该行更改为以下内容:
.Parameters.Append .CreateParameter("@ParameterEmail", adVarChar, adParamInput, Len(email), email)
我收到此错误Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
我不知道为什么我会收到此错误。不确定我的大脑是否被炒过。任何帮助将不胜感激!
答案 0 :(得分:2)
这里有几个问题: -
var
不是VBScript中的关键字。您需要使用Dim
*
时,您的行继续符_
之前有一个迷路星号(execSQL
)。这应该删除。email
子句中的WHERE
分配错误的参数。adVarChar
和adInputParameter
,因为这些是未知的。您需要用它们的数值替换它们。同样,为了完整性和良好实践,您应该在CommandType
对象上明确设置Command
属性,以使其不被假定为#34;属于adCommandText
。Recordset
对象上设置了Command
,则无法在打开Const adParamInput = 1
Const adVarChar = 200
Const adCmdText = 1
Dim execSQL
execSQL = ""
''' Set the SQL based on request type '''
If isSubscriber = true Then
execSQL = "select stuff from dbo.stuff WHERE field1 = 12" _
" AND email= @ParameterEmail" & _
" AND password= @ParameterPwd" & _
" AND EndDate >= GETDATE() "
Else
execSQL = "select stuff from dbo.stuff2 WHERE field1 = 12" _
" AND email= @ParameterEmail" & _
" AND password= @ParameterPwd" & _
" AND EndDate >= GETDATE() "
End If
Set cmd = Server.CreateObject("ADODB.Command")
''' Create the command with the appropriate SQL and params '''
With cmd
.activeconnection=conn
.commandtype = adCmdText
.commandtext= execSQL
'Create the parameter (name,type,direction,size,value)
.Parameters.Append .CreateParameter("@ParameterEmail", adVarChar, adParamInput, Len(email), email)
.Parameters.Append .CreateParameter("@ParameterPwd", adVarChar, adParamInput, Len(pwd), pwd)
End With
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open cmd
时设置连接对象以下是MSDN链接,用于显示参数枚举的数值: -
希望有所帮助。
itemnumber = parameter.AuxProperty.ContainsKey("art_nr")?parameter.AuxProperty["art_nr"].ToString():String.Empty;