gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 08:04:07 24 4
gpt4 key购买 nike

我正在做类似的事情

...
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 aninappropriate name, perhaps a reserved word.

Action: Change the variable name and retry the operation.

来自 here

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

关于c# - 在 C# 中执行参数化查询时出现 ORA-01745 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16104218/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com