I am trying to connect to an oracle database using C#.
Here is my code:
OracleConnection conn = new OracleConnection(); // C#
conn.ConnectionString = oradb;
conn.Open();
string sql = " select department_name from departments where department_id = 10"; // C#
OracleCommand cmd = new OracleCommand();
cmd.CommandText = sql;
cmd.Connection = conn;
cmd.CommandType = CommandType.Text; ///this is the line that gives the error
What is the proper way to set the command type? Thank you.
SOexample to follow I suggest you get familiar withusingstatement and how to wrap your code for disposing automatically as well stackoverflow.com/questions/3101786/… also learn how to useParameterized querysI doubt that you will be wanting to hard code your Where Filtercmd.ExecuteReader()intentionally.