ORA-01036: illegal variable name/number when running query through C#
c#, oracle
Solution
Just for others getting this error and looking for info on it, it is also thrown if you happen to pass a binding parameter and then never use it. I couldn't really find that stated clearly anywhere but had to prove it through trial and error.
Problem
I am trying to use `ALTER USER` query for Oracle database using OracleCommand in C# in the following code. It creates the query if the values for Username and password are not empty strings. But I get an error `"ORA-01036: illegal variable name/number"` when `ExecuteNonQuery()` is executed. ``` string updateQuery = "ALTER USER :user IDENTIFIED BY :password"; connection = new OracleConnection(LoginPage.connectionString); connection.Open(); OracleCommand cmd = new OracleCommand(updateQuery, connection); cmd.Connection = connection; for(int i=0;i<usersList.Count;i++) { if (!(selectedUsersArray[i].Equals("")) && !passwordArray[i].Equals("")) { OracleParameter userName = new OracleParameter(); userName.ParameterName = "user"; userName.Value = selectedUsersArray[i]; OracleParameter passwd = new OracleParameter(); passwd.ParameterName = "password"; passwd.Value = passwordArray[i]; cmd.Parameters.Add(userName); cmd.Parameters.Add(passwd); cmd.Prepare(); cmd.ExecuteNonQuery(); } } ``` Could you please suggest what is wrong with my implementation?.