类型不匹配:'[string:“”]'

Efe*_*cel 5 asp-classic

当querystring没有值时,我收到以下错误。(我的意思是像index.asp?ID =)。

Microsoft VBScript运行时错误'800a000d'

类型不匹配:'[string:“”]'

index.asp,第10行

我尝试使用以下代码将NULL值转换为其他值。这没用。

MEMBERID        = Request.QueryString("ID")

If MEMBERID = "" or MEMBERID = 0 Then
    MEMBERID = Session("MEMBERID")
End If
Run Code Online (Sandbox Code Playgroud)

Pau*_*tos 3

好的,您将从 QueryString 中获取参数 ID 并检查它是否为空或为零,对吧?所以,你应该这样做:

MemberId = Request.QueryString("ID")
'*
'* Check for other than numbers just to be safe
'*
If (MemberId = "" Or Not IsNumeric(MemberId)) Then
   MemberId = Session("MemberId")
End If
'*
'* We can't add this check on the above if because
'* in classic ASP, the expression is evaluated as a whole
'* which would generate an exception when converting to Int
'*
If (CInt(MemberId) = 0) Then
   MemberId = Session("MemberId")
End If
Run Code Online (Sandbox Code Playgroud)