2017-04-25 64 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

更新了我的答案並提供了一種潛在的解決方法 –

相關問題