I'm trying to make an insert into a table and it always gives me the error 00936 that says missing expression when it arrives at the cmd.executenonquery command line. Can someone help me? Code that I have:
using (OracleConnection conn = new OracleConnection(ConfigurationManager
.ConnectionStrings["CegosReportsOra"].ConnectionString))
{
conn.Open();
using (OracleCommand cmd = new OracleCommand())
{
String lang = System.Threading.Thread.CurrentThread.CurrentUICulture.ToString();
lang = "";
cmd.CommandType = CommandType.Text;
cmd.Connection = conn;
cmd.CommandText = "INSERT INTO ECICalendarEvent_Test(title, description, event_start, event_end, all_day) Values(@title, @description, @event_start, @event_end, @all_day)";
cmd.Parameters.Add("@title", OracleDbType.Varchar2).Value = cevent.title;
cmd.Parameters.Add("@description", OracleDbType.Varchar2).Value = cevent.description;
cmd.Parameters.Add("@event_start", OracleDbType.Date).Value = cevent.start;
cmd.Parameters.Add("@event_end", OracleDbType.Date).Value = cevent.end;
cmd.Parameters.Add("@all_day", OracleDbType.Char).Value = cevent.allDay;
cmd.ExecuteNonQuery();
int key = 0;
using (conn)
{
//get primary key of inserted row
cmd.CommandText = "SELECT max(event_id) FROM ECICalendarEvent_Test where title=@title AND description=@description AND event_start=@event_start AND event_end=@event_end AND all_day=@all_day";
cmd.Parameters.Add("@title", OracleDbType.Varchar2).Value = cevent.title;
cmd.Parameters.Add("@description", OracleDbType.Varchar2).Value = cevent.description;
cmd.Parameters.Add("@event_start", OracleDbType.Date).Value = cevent.start;
cmd.Parameters.Add("@event_end", OracleDbType.Date).Value = cevent.end;
cmd.Parameters.Add("@all_day", OracleDbType.Char).Value = cevent.allDay;
key = (int)cmd.ExecuteScalar();
}
return key;
}
The problem is with running the executenonquery line. Can anyone tell me what I'm forgetting? Thank you. I have a table with 6 columns in which one of them is the primary key (ID). Help me ...