Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Using parameterized queries would go long way toward protecting you from SQL injection attacks, because most bad things happen in the value portion of your <code>where</code> conditions.</p> <p>For exampleg given a condition <code>a=="hello" &amp;&amp; b=="WORLD"</code>, do this:</p> <pre><code>select a,b,c,d from table where a=@pa and b=@pb -- this is generated dynamically </code></pre> <p>Then, bind <code>@pa="hello"</code> and <code>@pb="WORLD"</code>, and run your query.</p> <p>In C#, you would start with an in-memory representation of your <code>where</code> clause in hand, go through it element-by-element, and produce two output objects:</p> <ul> <li>A string with the <code>where</code> clause, where constants are replaced by automatically generated parameter references <code>pa</code>, <code>pb</code>, and so on (use your favorite naming scheme for these blind parameters: the actual names do not matter)</li> <li>A dictionary of name-value pairs, where names correspond to the parameters that you've inserted in your <code>where</code> clause, and values that correspond to the constants that you pulled from the expression representation.</li> </ul> <p>With these outputs in hand, you prepare your dynamic query using the string, add parameter values using the dictionary, and then execute the query against your RDBMS source.</p> <p><strong>DO NOT DO THIS</strong></p> <pre><code>select a,b,c,d from table where a='hello' and b='WORLD' -- This dynamic query is ripe for an interjection attack </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload