title: SQL parameters not returning any results
body: <p>Following code is not returning any results:</p>
  
  <pre class="lang-vb prettyprint-override"><code>search = "'%" &amp; Request.QueryString("itemname") &amp; "%'"
  
  Set cmd = Server.CreateObject("ADODB.COMMAND")  
  Set cmd.ActiveConnection = conn
  
  sql = ""
  sql = sql &amp; "DECLARE @search varchar;"
  sql = sql &amp; "SET @search = ?;"
  
  sql = sql &amp; "SELECT ID, itemname, itemtype FROM vw_items WHERE itemname LIKE @search"
  
      cmd.CommandText = sql
      cmd.CommandType = adCmdText
  
  response.write("&lt;strong&gt;You searched for:&lt;/strong&gt; " &amp; search &amp; "&lt;br /&gt;&lt;br 
  /&gt;")    
  
  cmd.Parameters.Append cmd.CreateParameter("@search", adVarchar, adParamInput, 50, search)
  
  set rs = cmd.Execute
  else
  
      search = null
      strSQL2 =   "SELECT * FROM vw_items"
      set rs = server.CreateObject("ADODB.Recordset")
      rs.open strSQL2,conn
  
  end if
  </code></pre>
  
  <p>I've seen this answer: <a href="https://stackoverflow.com/questions/36154160/ado-parameterised-query-not-returning-any-result">ADO parameterised query not returning any result</a> and tried fixing mine but no luck</p>
  
  <p>Any help would be much appreciated</p>