I’m pulling a field from a table and doing different things depending on what the result is. Here’s my code
<%stringA ="Select field From table Where something=1"
set response = connFW.Execute(stringA )
set result = response ("field")
If result ="y" Then
Response.Write("The field is: " & result )
End If%>
It outputs this:
The field is: y
Then, later, I have an If statement:
<% ElseIf result ="y" or Session("customer_id") <> "" Then
Do Something
%>
But it never executes what’s in the ElseIf statement! It says right at the top of the page that it gave the correct result! Am I missing something?
Note: To avoid confusion, this code is at the top of the page:
Set connFW = Server.CreateObject("ADODB.Connection")
connFW.ConnectionTimeout = Application("FW_ConnectionTimeout")
connFW.CommandTimeout = Application("FW_CommandTimeout")
connFW.Open Application("FW_ConnectionString")
Without seeing your complete code, it’s hard to see where the exact problem is, but I see two possibilities. Either you have an “ElseIf” on its own, in which case you should change ElseIf to just plain If:
…or you are placing your ElseIf after your previous one:
If it’s the latter, then your ElseIf will not execute because the result = “y” condition has already been met in the previous If-statement.