title: ASP.NET C# Missing Expression Error during Oracle insert
body: <p>May I start off by saying this is my 1st assigned database project in 10 years... and 1st time doing it in C#. I am "simply" trying to insert form data into an Oracle table using OleDB.</p>
  
  <p>I keep getting "ORA-00936: missing expression". Below is my code... any idea what's missing?</p>
  
  <pre><code>public string getConnString()
          {
              //set the connection string from web config file
              return WebConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;
          }
  
          private void executeInsert(string EventType, string EventSubType, string DeptName, string EventDate, string Duration, string EventName, string EventAdd, string WardNo, string Program, string NumAtt, string StTime, string EndTime, string MngName, string RecKeeper)
          {
              OleDbConnection conn = new OleDbConnection(getConnString());
              string sql = "INSERT INTO APPS.CLV_EVENT_TRACK (EVENTTYPE, EVENTSUBTYPE, DEPTNAME, EVENTDATE, DURATION, EVENTNAME, EVENTADD, WARDNO, PROGRAM, NUMATT, STARTTIME, ENDTIME, MNGNAME, RECORDKEEPER) VALUES "
                  + "(@EventType, @EventSubType, @DeptName, TO_DATE(@EventDate, 'Month dd, YYYY'), @Duration, @EventName, @EventAdd, @WardNo, @Program, @NumAtt, TO_DATE(@StTime, 'HH:MI:SS PM'), TO_DATE(@EndTime, 'HH:MI:SS PM'), @MngName, @RecKeeper)";
  
              try
              {
                  conn.Open();
                  OleDbCommand cmd = new OleDbCommand(sql, conn);
                  OleDbParameter[] param = new OleDbParameter[14];
                  param[0] = new OleDbParameter("@EventType", OleDbType.VarChar, 25);
                  param[1] = new OleDbParameter("@EventSubType", OleDbType.VarChar, 80);
                  param[2] = new OleDbParameter("@DeptName", OleDbType.VarChar, 240);
                  param[3] = new OleDbParameter("@EventDate", OleDbType.Date);
                  param[4] = new OleDbParameter("@Duration", OleDbType.Numeric);
                  param[5] = new OleDbParameter("@EventName", OleDbType.VarChar, 80);
                  param[6] = new OleDbParameter("@EventAdd", OleDbType.VarChar, 150);
                  param[7] = new OleDbParameter("@WardNo", OleDbType.VarChar, 25);
                  param[8] = new OleDbParameter("@Program", OleDbType.VarChar, 150);
                  param[9] = new OleDbParameter("@NumAtt", OleDbType.Numeric);
                  param[10] = new OleDbParameter("@StTime", OleDbType.Date);
                  param[11] = new OleDbParameter("@EndTime", OleDbType.Date);
                  param[12] = new OleDbParameter("@MngName", OleDbType.VarChar, 150);
                  param[13] = new OleDbParameter("@RecKeeper", OleDbType.VarChar, 150);
  
                  param[0].Value = EventType;
                  param[1].Value = EventSubType;
                  param[2].Value = DeptName;
                  param[3].Value = EventDate;
                  param[4].Value = Duration;
                  param[5].Value = EventName;
                  param[6].Value = EventAdd;
                  param[7].Value = WardNo;
                  param[8].Value = Program;
                  param[9].Value = NumAtt;
                  param[10].Value = StTime;
                  param[11].Value = EndTime;
                  param[12].Value = MngName;
                  param[13].Value = RecKeeper;
  
                  for (int i = 0; i &lt; param.Length; i++)
                  {
                      cmd.Parameters.Add(param[i]);
                  }
  
                  cmd.CommandType = System.Data.CommandType.Text;
                  cmd.ExecuteNonQuery();
              }
  
              catch (Exception ex) { throw ex; }
  
              finally
              {
                  conn.Close();
              }
          }
  
          protected void btnSubmit_Click(object sender, EventArgs e)
          {
              var start = DateTime.Parse(txtStTime.Text);
              var end = DateTime.Parse(txtEndTime.Text);
  
              TimeSpan duration = end.Subtract(start);
              string meetDuration = duration.TotalMinutes.ToString();
  
              executeInsert(rbEventType.SelectedItem.Text, ddVolType.SelectedItem.Text,
                  txtDept.Text, txtEventDate.Text, meetDuration, txtEventName.Text,
                  txtEventAdd.Text, ddWard.SelectedItem.Value, txtSBPlan.Text, txtNumVol.Text,
                  txtStTime.Text, txtEndTime.Text, txtEventMgr.Text, txtRecording.Text);
          }
  </code></pre>
  
  <p><strong>UPDATE to code:</strong></p>
  
  <pre><code>public string getConnString()
          {
              //set the connection string from web config file
              return WebConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;
          }
  
          private void executeInsert(string EventType, string EventSubType, string DeptName, string EventDate, string Duration, string EventName, string EventAdd, string WardNo, string Program, string NumAtt, string StTime, string EndTime, string MngName, string RecKeeper)
          {
  
              OleDbConnection conn = new OleDbConnection(getConnString());
              string sql = "INSERT INTO APPS.CLV_EVENT_TRACK (EVENTTYPE, EVENTSUBTYPE, DEPTNAME, EVENTDATE, DURATION, EVENTNAME, EVENTADD, WARDNO, PROGRAM, NUMATT, STARTTIME, ENDTIME, MNGNAME, RECORDKEEPER) VALUES "
                  + "(@EventType, @EventSubType, @DeptName, TO_DATE(@EventDate, 'Month dd, YYYY'), @Duration, @EventName, @EventAdd, @WardNo, @Program, @NumAtt, TO_DATE(@StTime, 'HH:MI:SS PM'), TO_DATE(@EndTime, 'HH:MI:SS PM'), @MngName, @RecKeeper)";
  
              try
              {
                  conn.Open();
                  using (OleDbCommand cmd = conn.CreateCommand())
                  {
                      cmd.CommandText = sql;
  
                      cmd.Parameters.AddRange(new OleDbParameter[]
                      {
                          new OleDbParameter("@EventType", EventType),
                          new OleDbParameter("@EventSubType", EventSubType),
                          new OleDbParameter("@DeptName", DeptName),
                          new OleDbParameter("@EventDate", EventDate),
                          new OleDbParameter("@Duration", Duration),
                          new OleDbParameter("@EventName", EventName),
                          new OleDbParameter("@EventAdd", EventAdd),
                          new OleDbParameter("@WardNo", WardNo),
                          new OleDbParameter("@Program", Program),
                          new OleDbParameter("@NumAtt", NumAtt),
                          new OleDbParameter("@StTime", StTime),
                          new OleDbParameter("@EndTime", EndTime),
                          new OleDbParameter("@MngName", MngName),
                          new OleDbParameter("@RecKeeper", RecKeeper)
                      });
  
                      cmd.ExecuteNonQuery();
                  }
              }
  
              catch (Exception ex) { throw ex; }
  
              finally
              {
                  conn.Close();
              }
          }
  
          protected void btnSubmit_Click(object sender, EventArgs e)
          {
  
              var start = DateTime.Parse(txtStTime.Text);
              var end = DateTime.Parse(txtEndTime.Text);
  
              TimeSpan duration = end.Subtract(start);
              string meetDuration = duration.TotalMinutes.ToString();
  
              executeInsert(rbEventType.SelectedItem.Text, ddVolType.SelectedItem.Text,
                  txtDept.Text, txtEventDate.Text, meetDuration, txtEventName.Text,
                  txtEventAdd.Text, ddWard.SelectedItem.Value, txtSBPlan.Text, txtNumVol.Text,
                  txtStTime.Text, txtEndTime.Text, txtEventMgr.Text, txtRecording.Text);
          }
  </code></pre>