title: Incorrect syntax for SELECT TOP with a Parameter
body: <p>I used to have this one</p>
  
  <pre><code>Dt = MyMod.GetDataTable("SELECT TOP " &amp; QuestionsPerCats(i) &amp; " * From Questions WHERE CategoriesID ='" &amp; Cats(i) &amp; "' ORDER BY NEWID()")
  </code></pre>
  
  <p>but now i decided to use sqlparameters like </p>
  
  <pre><code>Dim cmd As New SqlCommand("SELECT TOP @QuestionsPerCats * From Questions WHERE CategoriesID = @CategoriesID ORDER BY NEWID()", conn)
  Dim sqlParam As SqlParameter = Nothing
  sqlParam = cmd.Parameters.Add("@QuestionsPerCats", SqlDbType.SmallInt)
  sqlParam.Value = QuestionsPerCats(i)
  sqlParam = cmd.Parameters.Add("@CategoriesID", SqlDbType.SmallInt)
  sqlParam.Value = Cats(i)
  </code></pre>
  
  <p>which unfortunately "renders" like </p>
  
  <pre><code>SELECT TOP @QuestionsPerCats * From Questions WHERE CategoriesID = @CategoriesID ORDER BY NEWID()
  </code></pre>
  
  <p>and returns the following error</p>
  
  <pre><code>Incorrect syntax near '@QuestionsPerCats'.
  </code></pre>
  
  <p>So what am i doing wrong here?</p>