我有一个查询,它检查用户是否存在于数据库中。当我通过OracleCommand检查这个查询时,它会导致异常,并指出command没有正确结束。
以下是查询:
select count(*) as user_exists
from users
where upper(u_name) = upper('name')
and u_password = DB_PKG_ACCESS.f_encrypt('pass')
and (expiration_date is null or (expiration_date is not null and trunc(expiration_date) >= trunc(sysdate)));这是command
OracleCommand cmd = new OracleCommand("select count(*) as user_exists from users where upper(u_name) = upper('name')"
+" and u_password = DB_PKG_ACCESS.f_encrypt('pass')"
+" and(expiration_date is null or(expiration_date is not null and trunc(expiration_date) >= trunc(sysdate)));", con);
cmd.Parameters.Add(new OracleParameter("name", textBox1.Text));
cmd.Parameters.Add(new OracleParameter("pass", textBox2.Text));我哪里错了?
发布于 2017-05-19 19:15:59
尝试从OracleCommand语句的末尾取出分号,如下所示
OracleCommand cmd = new OracleCommand("select count(*) as user_exists from users where upper(u_name) = upper('name')"
+" and u_password = DB_PKG_ACCESS.f_encrypt('pass')"
+" and(expiration_date is null or(expiration_date is not null and trunc(expiration_date) >= trunc(sysdate))) ", con);这对我来说是个问题.
HTH
发布于 2017-05-19 19:16:34
尝试删除查询中的分号(命令对象自动结束)
OracleCommand cmd = new OracleCommand("select count(*) as user_exists from users where upper(u_name) = upper('name')"
+" and u_password = DB_PKG_ACCESS.f_encrypt('pass')"
+" and(expiration_date is null or(expiration_date is not null and trunc(expiration_date) >= trunc(sysdate))); <==== Here remove it", con);https://stackoverflow.com/questions/44077433
复制相似问题