无效字符错误SQL, OracleDataReader

本文关键字:OracleDataReader SQL 错误 字符 无效 | 更新日期: 2023-09-27 18:11:54

代码卡在

    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;
    }

无效字符错误SQL, OracleDataReader

您必须删除查询字符串末尾的分号。因为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;
}