title: Parameterized Query for MySQL with C#
body: <p>I have the code below (I've included what I believe are all relevant sections):</p>
  
  <pre><code>private String readCommand = "SELECT LEVEL FROM USERS WHERE VAL_1 = ? AND VAL_@ = ?;";
  public bool read(string id)
  {
      level = -1;
      MySqlCommand m = new MySqlCommand(readCommand);
      m.Parameters.Add(new MySqlParameter("", val1));
      m.Parameters.Add(new MySqlParameter("", val2));
      MySqlDataReader r = m.ExecuteReader();
      if (r.HasRows)
          level = Convert.ToInt32(r.GetValue(0).ToString());
      r.Close();
      return true;
  }
  </code></pre>
  
  <p>When I run this, I get an IndexOutOfBoundsException on adding the first parameter. What have I done wrong?</p>