我依次尝试了以下所有方法:
1) // 就像在遗留代码中一样
ocmd.CommandText = "SELECT TRUNC(SYSDATE,''DD'') "VALUE" FROM DUAL";
2) // 添加@
ocmd.CommandText = @"SELECT TRUNC(SYSDATE,''DD'') "VALUE" FROM DUAL";
3) // 尝试单引号
ocmd.CommandText = "SELECT TRUNC(SYSDATE,''DD'') 'VALUE' FROM DUAL";
4) // 尝试两个单引号,例如 DD
ocmd.CommandText = "SELECT TRUNC(SYSDATE,''DD'') ''VALUE'' FROM DUAL";
5) // 试试@
ocmd.CommandText = @"SELECT TRUNC(SYSDATE,''DD'') ''VALUE'' FROM DUAL";
1和2给了我编译时错误:“;预期”(在“价值”上)
3、4 和 5 给了我,“Message=ORA-00907:缺少右括号”