Why the semicolon(‘;’) couldn’t place in the CommandText of a OracleCommand when C#
Just like below:
string sql = "select * from table1;";
OracleCommand oc = new OracleCommand(sql , con);
oc.CommandType = CommandType.Text;
oc.ExecuteNonQuery();
The result would turn out to be a error.
Why? Can any one tell me the reason?
In the comments, we’ve worked out the answer for you. Just so you get an official “answer”, here it is from the OracleOverflow site (see below):
Edit: This was the original link, which is now dead: http://www.oracleoverflow.com/questions/145/running-ddl-through-an-oraclecommand-without-the-semicolon
Alternative: http://web.archive.org/web/20100806014022/http://www.oracleoverflow.com/questions/145/running-ddl-through-an-oraclecommand-without-the-semicolon
Question:
Answer here:
Comments:
Why OracleCommand has this limitation of only being able to run 1 statement at a time?
It’s based on DbCommand specification in ADO.Net. It’s not a limitation of OracleCommand only.
SqlCommand allows multiple statements in a single command, that must just be an ‘addition’ for SQL Server.