title: Save variable to session in VB.net
body: <p>This is the code inside of my Handler.ashx at the end of this loop I want to save the variable whereclause to the session so it will know what the previous where clause was.</p>
  
  <p>I am open to any way of doing it, but I believe saving to the session would help me complete this.</p>
  
  <p>I tried: <code>Session["whereclause"] = whereclause</code> but it gave me an error     </p>
  
  <pre class="lang-vb prettyprint-override"><code>'4.3 Filtering implementation
  If Not (FilterTerm = "" Or FilterCol = "") Then
      If Not (FilterCol = "[Study Time]") And InStr(whereclause, "WHERE", vbTextCompare) = 0 Then
          whereclause = whereclause &amp; " WHERE " &amp; FilterCol &amp; " = '" &amp; FilterTerm &amp; "'"
      ElseIf InStr(whereclause, "WHERE", vbTextCompare) = 0 And FilterCol = "[Study Time]" Then
          whereclause = whereclause &amp; " WHERE " &amp; FilterCol &amp; " = '12/30/1899 " &amp; FilterTerm &amp; "'"
      ElseIf (FilterCol = "[Study Time]") Then
          whereclause = whereclause &amp; " AND " &amp; FilterCol &amp; " = '12/30/1899 " &amp; FilterTerm &amp; "'"
      Else
          whereclause = whereclause &amp; " AND " &amp; FilterCol &amp; " = '" &amp; FilterTerm &amp; "'"
      End If
  End If
  </code></pre>