2017-04-25 83 views
-1

下面是我的传统的ASP应用程序的我的服务器端ASP代码:ASP LEN()函数返回类型不匹配错误

Function isValidPACSSession() 
... 
Dim sessionID : sessionID = Request.QueryString("forSessionID") 
isValidPACSSession = SessionID2PACSUserID(sessionID) 
... 
End Function 

Function SessionID2PACSUserID(sSessionID) 
if (Not IsNull(sSessionID) AND Len(sSessionID) > 0) then 
      ...it fails here at the Len function. 
     else 
      ... 
     end if 
End Function 

LEN()函数抛出此partcular例如“类型不匹配”的错误,wheras其他电话由其他组件创建SessionID2PACSUserID()就好了。请帮忙。

+0

如果'Request.QueryString(“forSessionID”)'为null,它将会失败,请确保它不是通过这个小技巧'sessionID = Request.QueryString(“forSessionID”)&“”'或Len(sSessionID &“”)'*(个人喜欢在设置我的变量时做)*。更大的问题是,为什么你传递sessionID作为查询字符串? – Lankymart

+0

可能重复[如果不是在ASP经典](http://stackoverflow.com/questions/33254463/if-not-isnull-in-asp-classic) – Lankymart

+0

这是probelem,我检查了调试器 请求.QueryString(“forSessionID”)的值为字符串类型的“F50DAA7A37494A51A0A157D917FACF891129”。 len()函数抛出类型不匹配错误。 –

回答

0

找到了一个解决方案..其实我有一个名为“len”的calle网页导致len()失败的局部变量。将len变量名更改为nLength,Len()现在可以正常工作。

0

看起来像你只是想检查是否存在值,为什么不这样做:

dim sessionLength : sessionLength = 0 
if (Not IsNull(sSessionID) AND sSessionID <> "") then 
    sessionLength = Len(sSessionID) 

我也同意与调试器不工作的上述说法非常好,传统的ASP

+0

谢谢。但我也需要字符串的长度来使用它的数据库查询purpsose。 –

+0

更新了我的答案并提供了一种潜在的解决方法 –