title: protected DataSet against SQL Inejection
body: <p>I want to create a class that I can get datatable of specific table given in the parameter of the constructor.</p>
  <p>But how I can do it without it being vulnerable to SQL Injections?</p>
  <p>I would've done something like this: (But you can't use those statements like that)</p>
  <pre><code>public class SqlClass
  {
  
      DataTable dt;
  
      string table;
  
      public SqlClass(String table)
      {
          this.table = table;
          SqlConnection c = new SqlConnection();
          c.conOpen();
          MySqlCommand msc = new MySqlCommand(&quot;SELECT * FROM @tableName&quot;, c.Con); //Cant do that
          msc.Parameters.AddWithValue(&quot;@tableName&quot;, table);
          DataSet ds = c.getDataSet(msc, table);
          this.dt = ds.Tables[table];
          c.conClose();
      }
  
      public DataTable Dt { get =&gt; dt; set { dt = value; } }
  
  }
  </code></pre>
  <p>Any other working alternative that won't harm me? Thanks.</p>