加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

在C#中执行参数化查询时出错ORA-01745

发布时间:2020-12-15 18:14:16 所属栏目:百科 来源:网络整理
导读:我在做类似的事情 ...OracleCommand oCommand = new OracleCommand();oConnection.Open();oCommand.Connection = oConnection;oCommand.CommandText = "SELECT * FROM employees WHERE user = :User";oCommand.Parameters.AddWithValue(":Name","Employee1")
我在做类似的事情
...
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();

那么这会抛出一个例外:

ORA-01745: invalid host/bind variable name

编辑:连接字符串如下所示:

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

oConnection.Open();所以我假设我的连接字符串是正确的.

我在哪一方面犯错?

解决方法

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.

从here

要检查什么是保留字,单击here

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读