System exception error in Oracle

Hi Everyone,

I have the below code and it throws a system exception error.  And, I don't see anything what is causing the error.

private String GetEntityNames(string tableName)
            string e = null;
            string ConString = "User Id=sys;Password=sys;Data Source=T";
            using (OracleConnection con = new OracleConnection(ConString))
                OracleDataAdapter adapter = new OracleDataAdapter();
                OracleCommand command = new OracleCommand("SELECT Y_NUMBER FROM T.E WHERE E_N=" + tableName, con); 
                adapter.SelectCommand = command;
                DataSet dataset = new DataSet("PSR");
                foreach (DataRow dr in dataset.Tables[0].Rows)
                   eNumber = dr["Y_NUMBER"].ToString();

            return eNumber;

Open in new window

Can you please help around this?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Difficult to say if you keep the error message(s) a secret.
o0JoeCool0oAuthor Commented:
It says 'ORA:00904 Invalid identifier'.
käµfm³d 👽Commented:
If the type of the column "E_N" is VARCHAR/VARCHAR2, then you need to have a string in your query (i.e. single quote it):

OracleCommand command = new OracleCommand("SELECT Y_NUMBER FROM T.E WHERE E_N='" + tableName + "'", con);

Open in new window

But keep in mind that building a query by string concatenation opens you up for SQL Injection attacks. It would be better to use parameterized queries.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.