Type of mismatch: '[string: ""]'

I get the following error when there is no value for the request. (I mean, how is index.asp? ID =).

Microsoft VBScript '800a000d' Runtime Error

Type mismatch: '[string: ""]'

index.asp line 10

I tried converting a NULL value to something else with the following code. This did not work.

MEMBERID = Request.QueryString("ID") If MEMBERID = "" or MEMBERID = 0 Then MEMBERID = Session("MEMBERID") End If 
+4
source share
5 answers

OK, you get the parameter identifier from QueryString and check if it is empty or not, right? So you should do something like:

 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 
+3
source

If you want to convert zero to an empty string, use the string concatenation operator & :

 MEMBERID = Request.QueryString("ID") & "" 
+2
source

Check Nothing:

 IF Request.QueryString("ID") IS Nothing Then ... End If 
0
source

Here's how I do it: -

  dim memberID : memberID = Request.QueryString("ID") if memberID <> "" then memberID = CLng(memberID) if memberID = Empty then memberID = Session("MemberID") 

The item QueryString property returns either Empty or String . He will never return an integer.

If memberID is not parsed as an integer, then this code will be erroneous. However, if the value in the ID must be an integer, but really is something else, I would like it to fail.

Empty compared with both the null string and the number 0.

0
source

Well, in my case, the code was something like this:

 if TRIM(variavel) <> "0" then variavel = "1" end if 

And the "default" solution here is where I work:

 if isNull(variavel) then variavel = "1" end if 

Hope this helps.

0
source

All Articles