Search code examples
asp-classic

How to set value 1 (integer) into an variable inside IF clause in ASP classic?


I'm currently working on a webpage using ASP Classic. I have created an If statement, if the company id is equal to 1, then the variable receives a connection.execute. Else, the variable must receive an fixed value of 1. For some reason it's not working. I've tried to google the correct syntax for such case, but I haven't been successful... here is the part of the code I have just told you guys about:

<%
Dim integrated_code
if SESSION("Company_ID") = 1 Then
    set integrated_code = connection.execute("SELECT TOP 1 ID_BLABLABLA FROM BLABLABLA")
Else
   set integrated_code = 1
End if
%>

Solution

  • Lose the "set", at least for the simple variable. The other one depends on the nature of "connection".

    <%
    Dim integrated_code
    If Session("Company_ID") = 1 Then
        Set integrated_code = connection.execute("...")
    Else
        integrated_code = 1
    End If
    %>