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

前端之家收集整理的这篇文章主要介绍了在C#中执行参数化查询时出错ORA-01745前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在做类似的事情
...
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

猜你在找的C#相关文章