首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OracleCommand未正确结束

OracleCommand未正确结束
EN

Stack Overflow用户
提问于 2017-05-19 19:11:08
回答 2查看 147关注 0票数 0

我有一个查询,它检查用户是否存在于数据库中。当我通过OracleCommand检查这个查询时,它会导致异常,并指出command没有正确结束。

以下是查询:

代码语言:javascript
复制
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

代码语言:javascript
复制
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));

我哪里错了?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-05-19 19:15:59

尝试从OracleCommand语句的末尾取出分号,如下所示

代码语言:javascript
复制
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

票数 2
EN

Stack Overflow用户

发布于 2017-05-19 19:16:34

尝试删除查询中的分号(命令对象自动结束)

代码语言:javascript
复制
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);
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44077433

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档