我从表中拉出一个字段,并根据结果做不同的事情。这里是我的代码不正确读取SQL字段的ASP代码
<%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%>
它输出这样的:
The field is: y
然后,后来,我有一个if语句:
<% ElseIf result ="y" or Session("customer_id") <> "" Then
Do Something
%>
但它从来没有执行什么在elseif的声明!它说在页面的顶部,它给出了正确的结果!我错过了什么吗?
注意:为了避免混乱,这个代码是在页面的顶部:
Set connFW = Server.CreateObject("ADODB.Connection")
connFW.ConnectionTimeout = Application("FW_ConnectionTimeout")
connFW.CommandTimeout = Application("FW_CommandTimeout")
connFW.Open Application("FW_ConnectionString")
如果您有条件结果=“y”的ElseIf,则首先得到满足如果控件将如何到达此行。所以最好在ElseIf中使用Session(“consumer_id”)<>“”或将其放在If块中。 – Ravia 2012-09-04 11:29:43