I am getting following Oracle error when I am trying to insert using parameterized query:
ORA-01036: illegal variable name/number
My code is:
OracleTransaction myTrans;
using (myTrans = myConnection.BeginTransaction())
{
try
{
OracleCommand cmd = new OracleCommand("INSERT INTO TABLE_NAME(GKEY,FILE_NAME,CONTAINER_NO) VALUES (1,@file_name,@container_no)", myConnection);
cmd.Parameters.AddWithValue("@file_name", file_name);
cmd.Parameters.AddWithValue("@container_no", container_no);
cmd.Transaction = myTrans;
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
myTrans.Rollback();
}
finally
{
myTrans.Commit();
}
}
When I use without parametrized query it working without any errors, please help me to solve this. Thanks
EDIT: I think this question is not a duplicate question, the answer provided below worked for me. Here I used "@" sign that is the main cause of the error. Please re-consider. Thanks