ORA-00911: invalid character

跟風遠走 提交于 2019-11-27 12:59:04

Remove ; (semi-colon) from the end of SQL string

In case other people wind up here looking for how to include multiple statements in a single command, you need to wrap your statements within begin and end. This will stop the invalid character errors due to the semi-colons. For example:

var command = new OracleCommand(@"
    begin
    select * from test;
    select * from test2;
    end;")

Why are you using semicolon in the query...It just be taken as invalid character..... You have to remove the semicolon(;) from the query and do like this:

   OracleConnection conn = new OracleConnection(-myConnectionString-);
   conn.Open();
    OracleCommand command = new OracleCommand("select * from test", conn);
    var v = command.ExecuteReader(); 
    OracleCommand command = new OracleCommand("select * from \"test\"", conn);
    var v = command.ExecuteReader(); 

For more detail of this error, you can read here.

This isn't this guy's problem, but hopefully this will help someone out there:

I often have this problem with single quotes hidden inside inline comments, like so:

select foo 
from bar
where 
/* some helpful comment with a "can't" or somesuch */
baz='qux'

The unmatched single quote in the comment causes all kinds of drama, and oracle doesn't go out of its way to help you figure that out.

Sohail

Replace the sqldatasource parameter ? with :Column_name in the delete, update and insert commands.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!