I’m trying to feed sqlcommand with more parameters than it uses. Because of that I’m getting exception ORA 01036. The description leads me to a fact that I can only pass parameters that will actually be used in the query.
I cannot find it anywhere – is it really true? It seems pretty stupid and limited to me…
I attempted to recreate your situation using System.Data.SqlClient.SqlConnection to connect to an Oracle database and was unsuccessful.
Using System.Data.OracleClient.OracleConnection I was able to test a query with and without parameters. The below code is successful with the uncommented ‘string sql …’. The commented ‘string sql’ will encounter the same error mentioned in your question.
This leads me to believe you are correct: when querying Oracle, the number of paramaters passed in the command must match the number of paramaters in the query.
a. When working with Oracle, I would also recommend you keep your paramaters in the same order as their usage in the query. Depending on what DLL you are using, the paramaters do not map based on paramater name, but by order of insertion.
Dave