Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ORA-01745 error while executing parameterized queries in c#

Tags:

c#

.net

oracle

I'm doing something like

...
OracleCommand oCommand = new OracleCommand();
oConnection.Open();
oCommand.Connection = oConnection;
oCommand.CommandText = "SELECT * FROM employees WHERE user = :User";
oCommand.Parameters.AddWithValue(":Name", "Employee1");

DbDataReader dbRdr = oCommand.ExecuteReader();

then this throws an exception:

ORA-01745: invalid host/bind variable name

EDIT: connection string looks like this:

"Data Source=orcl;Persist Security Info=True;User ID=user_id;Password=pwd;Unicode=True"

No error after the oConnection.Open(); so I assume my connection string is correct.

On which part did I make a mistake?

like image 292
Bahamut Avatar asked Apr 19 '13 12:04

Bahamut


1 Answers

ORA-01745: invalid host/bind variable name

Cause: A colon in a bind variable or INTO specification was followed by an inappropriate name, perhaps a reserved word.

Action: Change the variable name and retry the operation.

from here

To check what are reserved words, click here

like image 93
CloudyMarble Avatar answered Oct 01 '22 23:10

CloudyMarble