ORA-01745错误而执行在C#中参数化查询 [英] ORA-01745 error while executing parameterized queries in c#
问题描述
我在做这样的事情
...
的OracleCommand oCommand =新的OracleCommand();
oConnection.Open();
oCommand.Connection = oConnection;
oCommand.CommandText =SELECT * FROM雇员WHERE USER =:用户;
oCommand.Parameters.AddWithValue(:名称,Employee1);
DbDataReader dbRdr = oCommand.ExecuteReader();
那么这将引发异常:
ORA-01745:无效的主机/绑定变量名
编辑:连接字符串看起来是这样的:
数据源= ORCL;坚持安全信息= TRUE;用户ID = USER_ID;密码= PWD;统一code = TRUE
在没有错误的 oConnection.Open();
所以我想我的连接字符串是正确的。
在哪一部分没有我犯了一个错误?
ORA-01745 :无效的主机/绑定变量名
原因:在绑定变量或进入规范冒号之后由 不恰当的名字,也许是一个保留字。
动作:更改变量的名称和试操作
要检查什么是保留字,请点击这里
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?
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
这篇关于ORA-01745错误而执行在C#中参数化查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!