title: LIKE statement using parametrized SQL in vbscript
body: <p>I'm trying to create a LIKE SQL statement in vbscript using parametrized SQL. </p>
  
  <p>The command text passed through is along the lines of</p>
  
  <pre><code>SET NOCOUNT ON; 
  DECLARE @pname as nvarchar(50); 
  SELECT @pname = ?; 
  SELECT *
  FROM tblProject
  WHERE projName LIKE @pname
  </code></pre>
  
  <p>And I'm concatenating % onto either side of the string that I'm passing through as pname. If I change the LIKE to an = and remove the %s then it works fine. And if I run the statement directly and replace <em>@pname</em> with <em>'%searchterm%'</em> it works fine. Any help would be much appreciated. </p>
  
  <p>Edit: vbscript:</p>
  
  <pre><code>Set rsAnswers = Server.CreateObject("ADODB.Recordset")
  Set cmd = server.createobject("ADODB.Command")
  cmd.CommandText = mySQL
  cmd.CommandType = 1
  cmd.CommandTimeout = 900 
  cmd.ActiveConnection = svrPerformanceConnectionset prm = cmd.CreateParameter("@pname", 129, 1, 50, thisProjName)
  cmd.Parameters.Append prm
  rsAnswers.CursorLocation = 3
  rsAnswers.Open cmd, , 0, 1
  </code></pre>
  
  <p>(thisProjName is getting a string from a form)</p>
  
  <p>Thanks,
  Tim</p>