Link to home
Start Free TrialLog in
Avatar of triplebd69
triplebd69

asked on

C# insert into Oracle

I am new at this and need help with what I hope is a simple question.  I have a C# app that needs to insert records into an Oracle db.  The code I have runs without error but does not actually insert a record.  Here is my code so far.

string eEmpID = tbEmpID.Text;
string eFName = tbFName.Text;
string eLName = tbLName.Text;
string eEmail = tbEmail.Text;
string ePhone = tbPhone.Text;
string eHireDate = " ";
string eJobID = ddlJobID.SelectedValue;
string eGrade = ddlGrade.SelectedValue;
                  
using (OracleConnection con = new OracleConnection(Configuration.oConn))
{
con.Open();

string oCMD = "insert into RANDRAPP.EMPLOYEES(EMPLOYEE_ID, FIRST_NAME, LAST_NAME, EMAIL, PHONE_NUMBER, HIRE_DATE, JOB_ID, SALARY, MANAGER_ID, DEPT_ID, TIME_REMAINING) VALUES (eEmpID, eFName, eLName, eEmail, ePhone, eHire_Date, eJobID, eGrade)";

OracleCommand cmd = new OracleCommand(oCMD, con);
}
Avatar of dstanley9
dstanley9

Where are you actually executing the command?

try

OracleCommand cmd = new OracleCommand(oCMD, con);
cmd.ExecuteNonQuery();
Avatar of triplebd69

ASKER

Sorry I must have cut that off it is in the code.

Then that should be all you need.  If the SQL threw an error it would come back to you as an exception.  Not sure what else could be going on.  Do you have a try block anywhere that could be catching the exception?
Took it out.  Is there anything to do to get the value of these variables?  Do they need quotes or something?
ASKER CERTIFIED SOLUTION
Avatar of dstanley9
dstanley9

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Do I also need to a value for each column in the table?
Yes, you need a value for each column in the list of fields (in the same order as well).  I didn't catch that in your SQL either.
Thanks so much you have been a great help!