title: Which prefix should I use for MySql named parameters in C# using Connector/Net?
body: <p>I am using <a href="http://dev.mysql.com/downloads/connector/net/" rel="noreferrer">Connector/Net 6.8.3</a> for a C# project and have been using it (or prior versions) for quite some time.</p>
  
  <p>As I look through legacy code, I see several variations related to parameterized queries and have been attempting to determine what the differences are and if there's a best practice.</p>
  
  <h2>The query string:</h2>
  
  <ul>
  <li><p>Example 1: <code>cmd.CommandText = "UPDATE table SET thing = @value;";</code></p></li>
  <li><p>Example 2: <code>cmd.CommandText = "UPDATE table SET thing = ?value;";</code></p></li>
  </ul>
  
  <h2>Adding parameters:</h2>
  
  <ul>
  <li><p>Example 3: <code>cmd.Parameters.AddWithValue("@value", user_value);</code></p></li>
  <li><p>Example 4: <code>cmd.Parameters.AddWithValue("?value", user_value);</code></p></li>
  <li><p>Example 5: <code>cmd.Parameters.AddWithValue("value", user_value);</code></p></li>
  </ul>
  
  <p>All of these variations seem to work. I haven't been able to find in the official documentation anything that explains the difference in prefix usage (<code>@</code> vs <code>?</code>). However, <a href="http://www.devart.com/dotconnect/mysql/docs/Parameters.html" rel="noreferrer">this devart.com page</a> suggests the following:</p>
  
  <ul>
  <li>Unnamed parameters can be specified as '?' symbol.</li>
  <li>Named parameters are declared using ':' or '@' prefix followed by name of the parameter. Note that the name of the MySqlParameter object in the collection of the command should contain the '@' prefix if parameter in CommandText is used with the '@' prefix. If the parameter in CommandText contains the ':' prefix, the name of the MySqlParameter object in the command's collection should be used without any prefix.</li>
  </ul>
  
  <p>The last point has some grammatical issues, but the examples shown seem to indicate that when using '<code>@</code>' the statement <code>cmd.Parameters.AddWithValue("@value", user_value);</code> should include the '<code>@</code>' as well, but not when using '<code>:</code>'.</p>
  
  <p>However, in many of the functioning methods that I am reviewing, the query uses '<code>@</code>' in the command text <em>(Example 1)</em>, but <strong><em>not</em></strong> in the <code>AddWithValue()</code> statement <em>(Example 5)</em>.</p>
  
  <h2>Questions:</h2>
  
  <ul>
  <li><p>What are the potential consequences of omitting the prefix when adding a parameter? <em>(Example 5)</em></p></li>
  <li><p>Is there no reason to add a parameter name when using the '<code>?</code>' prefix, because it is intended for unnamed parameters? <em>(Example 2)</em></p></li>
  </ul>