在调用C#Oracle存储过程使用" Oracle.DataAccess" (带参数) [英] Calling an Oracle stored procedure in C# using "Oracle.DataAccess" (with a parameter)

查看:1785
本文介绍了在调用C#Oracle存储过程使用" Oracle.DataAccess" (带参数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我想从我的C#.NET应用程序中调用Oracle存储过程。大多数的网上参考我能找到的建议使用System.Data.OracleClient的;,但NET 3.5的不承认,所以我用Oracle.DataAccess.Client而不是命名空间

So I'm trying to call an Oracle stored procedure from my C# .NET application. Most online references I can find suggest "using System.Data.OracleClient;", but .Net 3.5 doesn't recognize that namespace so I'm using "Oracle.DataAccess.Client" instead.

下面是我的code以下一些转述,以previously安装和测试的OracleConnection称为'的myconn已经充满了参数:arg_myArg(这是一个数字,如果该事项):

Here's some paraphrasing of my code below, with a previously setup and tested OracleConnection called 'myConn' already filled with parameter ':arg_myArg' (it's a number, if that matters):

command.Connection = myConn;
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "exec mySchema.myProc(:arg_myArg)"
command.ExecuteNonQuery();

诀窍是,的程序返回任何内容设计,它只是填充不同的表,我从拉。然而,当我尝试运行上面的code,我得到的最终线OracleException,并给出了这样的错误:

The trick is that the procedure returns nothing by design, it simply populates a different table which I pull from. However, when I try to run the code above, I get a 'OracleException' on the final line and gives this error:

ORA-06550: line 1, column 13:
PLS-00103: Encountered the symbol "MYSCHEMA" when expecting one of the following:

   := . ( @ % ;
The symbol ":=" was substituted for "MYSCHEMA" to continue.

在命令删除执行给出了这样的错误,而不是:

Removing the "exec" from the command gives this error instead:

ORA-06550: line 1, column 8:
PLS-00801: internal error [22503]
ORA-06550: line 1, column 8:
PL/SQL: Statement ignored

任何想法?我很乐意澄清任何事情

Any ideas? I'd be happy to clarify anything

这是我第一次张贴stackoverflow.com和我上周在此工作,所以我AP preciate你的理解和搞清楚了这一点相对急速

This is my first time posting on stackoverflow.com and my last week at this job, so I appreciate your understanding and relative haste with figuring this out

推荐答案

我认为你需要像这样

command.Connection = myConn;
command.CommandType = CommandType.StoredProcedure;  
command.CommandText = "mySchema.myProc";  // the proc name   
command.Parameters.Add(/* TODO: Add parameter here */); 
command.ExecuteNonQuery();

这篇关于在调用C#Oracle存储过程使用" Oracle.DataAccess" (带参数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆