title: Using variables in SQL queries in asp.net (C#)
body: <p>I have an SQL query of this form</p>
  
  <pre><code>string cmdText = "Select * from " + searchTable 
    + "WHERE " + searchTable 
    + "Name =' " +   searchValue + "'";
  </code></pre>
  
  <p>Basically what I am trying to do is get a particular actor's info from the database's Actors table. The variable searchTable has the value 'Actor' which is the table name and searchValue has the actor's name (which is represented by the ActorName attribute in the Actor's table, here I am trying to form the name of the attribute by concatenating the words 'Actor' and 'Name' )</p>
  
  <p>So, well, all this concatenation results in (or at least should result in) a query of the form:</p>
  
  <pre><code>Select * from Actor where ActorName ='some actor';
  </code></pre>
  
  <p>But when I try to run this it gives me the error "Incorrect syntax near '=' " in the browser. Could anyone please help?</p>