title: Error says "Missing right parenthesis" in my SQL statement... but it's not! Help?
body: <p>Here's my statement from my C# program:</p>
  
  <p>(edit by gbn, formatted for clarity so not <em>all</em> on one line)</p>
  
  <pre><code>DbCommand.CommandText =
               @"SELECT 
        HIST.MBRSEP, HIST.LOCATION, HIST.BILLTYPE, HIST.BILLMOYR, LOCINFO.CYCLE, 
        LOCINFO.DIST, LOCINFO.LOCATION
      FROM 
        (CAV_MBRHISTDEL AS HIST INNER JOIN CAV_LOCINFODETL AS LOCINFO ON HIST.LOCATION = LOCINFO.LOCATION)
      WHERE
         LOCINFO.CYCLE = @CYCLE AND 
         LOCINFO.DIST = @DISTRICT AND 
         HIST.BILLTYPE = '09' AND 
         HIST.BILLMOYR &lt;&gt; '9999'";
  </code></pre>
  
  <p>Here's the error message:</p>
  
  <blockquote>
    <p>ERROR [HY000] [Oracle][ODBC][Ora]ORA-00907: missing right parenthesis</p>
  </blockquote>
  
  <p>There's only 2 parenthesis in my SQL statement, a right one and a left one.  I'm not sure what the error is telling me.  Any advice?</p>
  
  <p>EDIT:  Here is how the parameters are defined:</p>
  
  <pre><code>        string cycle = cbCycle.Text;
          string district = cbDistrict.Text.Substring(0,2);
  </code></pre>
  
  <p>And here is where I add them to the DbCommand:</p>
  
  <pre><code>        DbCommand.Parameters.AddWithValue("@CYCLE", cycle);
          DbCommand.Parameters.AddWithValue("@DISTRICT", district);
  </code></pre>
  
  <p>Here's my complete code that triggers when someone clicks the 'Go' button on my form:</p>
  
  <pre><code>private void btnGo_Click(object sender, EventArgs e)
      {
          //get parameters
          string cycle = cbCycle.Text;
          string district = cbDistrict.Text.Substring(0,2);
  
          //create a connection to the database
          OdbcConnection DbConnection = new OdbcConnection("DSN=UPN2;uid=xxx;pwd=xxxx");
          DbConnection.Open();
  
          //create a command to extract the required data and
          //assign it to the connection string
          OdbcCommand DbCommand = DbConnection.CreateCommand();
          DbCommand.CommandText =
               @"SELECT HIST.MBRSEP, HIST.LOCATION, HIST.BILLTYPE, HIST.BILLMOYR, LOCINFO.CYCLE, LOCINFO.DIST, LOCINFO.LOCATION FROM CAV_MBRHISTDEL AS HIST INNER JOIN CAV_LOCINFODETL AS LOCINFO ON HIST.LOCATION = LOCINFO.LOCATION WHERE LOCINFO.CYCLE = @CYCLE AND LOCINFO.DIST = @DISTRICT AND HIST.BILLTYPE = '09' AND HIST.BILLMOYR &lt;&gt; '9999'; ";
  
          DbCommand.Parameters.AddWithValue("@CYCLE", cycle);
          DbCommand.Parameters.AddWithValue("@DISTRICT", district);
  
          //Create a DataAdapter to run the command and fill the datatable
          OdbcDataAdapter da = new OdbcDataAdapter();
          da.SelectCommand = DbCommand;
          DataTable dt = new DataTable();
          da.Fill(dt);
  
  
          tbOutput.Text = PrintDataTable(dt);
  
          DbCommand.Dispose();
          DbConnection.Close();
  
      }
  </code></pre>