简体   繁体   English

OLEDB Oracle(11g)和C#的SQL无效语法

[英]SQL Invalid syntax with OLEDB Oracle (11g) and C#

Here is the query I want to run: 这是我要运行的查询:

SELECT COUNT(*) FROM Users WHERE name = @name AND pwd = @pwd;

My Connection String: 我的连接字符串:

Provider=OraOLEDB.Oracle;User Id = HR; Password = hr;

Specifications: 规格:

  • C# WinForms C#WinForms
  • Oracle 11 甲骨文11
  • OleDBCommand as command OleDBCommand作为命令
  • Using Oracle XE 使用Oracle XE

Steps I've tried: 我尝试过的步骤:

  • Script runs in sqldeveloper on the live server 脚本在实时服务器上的sqldeveloper中运行
  • Connection opens 连接打开
  • Listener is up and running 侦听器已启动并正在运行
  • Parameters 'name' and 'pwd' got through and are sent 参数“名称”和“ pwd”通过并发送

Error I'm getting: 我得到的错误:

ORA-00936: missing expression ORA-00936:缺少表达

In Oracle, parameters are prefixed with : instead of @ . 在Oracle中,参数以:代替@前缀。 Use that instead: 改用它:

SELECT COUNT(*) FROM Users WHERE name = :name AND pwd = :pwd;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM