gpt4 book ai didi

c# - 无效字符错误SQL,OracleDataReader

转载 作者:太空宇宙 更新时间:2023-11-03 19:57:00 26 4
gpt4 key购买 nike

代码卡在

    OracleDataReader reader = inst.Command.ExecuteReader();

出现错误 ORA-00911:无效字符(查询中)。我已经分别检查了查询的工作情况。请指导

    public DataSet Get_CurrentTask(Employee emp)
{
if (inst.isConnected == true)
{
string query = "SELECT employees.empl_id, employees.emp_name FROM employees LEFT JOIN TASK_SUM On employees.empl_id= TASK_SUM.emp_ID;";
Database inst.Command = new System.Data.OracleClient.OracleCommand(query, inst.getConnection());
inst.Command.CommandType = CommandType.Text;
OracleDataAdapter da= new OracleDataAdapter(inst.Command);
OracleCommandBuilder cb = new OracleCommandBuilder(da);
OracleDataReader reader = inst.Command.ExecuteReader();
DataSet ds = new DataSet();
da.Fill(ds);
}
return ds;
}

最佳答案

您必须删除查询字符串末尾的分号。因为 Oracle 命令方法会自动将分号添加到查询字符串的末尾。

所以,

   public DataSet Get_CurrentTask(Employee emp)
{
if (inst.isConnected == true)
{
string query = "SELECT employees.empl_id, employees.emp_name FROM employees LEFT JOIN TASK_SUM On employees.empl_id= TASK_SUM.emp_ID";
Database inst.Command = new System.Data.OracleClient.OracleCommand(query, inst.getConnection());
inst.Command.CommandType = CommandType.Text;
OracleDataAdapter da= new OracleDataAdapter(inst.Command);
OracleCommandBuilder cb = new OracleCommandBuilder(da);
OracleDataReader reader = inst.Command.ExecuteReader();
DataSet ds = new DataSet();
da.Fill(ds);
}
return ds;
}

必须工作。

关于c# - 无效字符错误SQL,OracleDataReader,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32471592/

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