OleDb存储过程调用问题 [英] OleDb Stored Procedure Call Problem

查看:93
本文介绍了OleDb存储过程调用问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,


我正在试图弄清楚如何编写一个C#程序来添加参数'''A"和B并返回C在以下代码中:


我在commnd.ExecuteNonQuery()时收到错误;声明如下。错误说明:


X2提供程序错误:< ExecuteHelper失败>

X2提供程序错误:<内部错误:无法获取IProc接口>


根据开发人员的说法,提供商与ADO.Net合作。


这是我到目前为止的代码:



I am trying to figure out how to write a C# program to add parameter''s "A" and "B" and return "C" in the following code:

I get an error at the commnd.ExecuteNonQuery(); statement below. The error states:

X2 Provider Error: <ExecuteHelper Failed>
X2 Provider Error: <Internal Error: Failed to get the IProc Interface>

The provider works with ADO.Net according to the developer.

Here''s the code I have so far:

展开 | 选择 | Wrap | 行号

推荐答案

好的我让它在我的列表框中使用以下代码返回一个值,但是6和5分别为var1和var2输入我在列表框中得到零。任何想法为什么commnd.Parameters [" C"]。值是null?可能是ExecuteNonQuery错了吗?


谢谢


这是我新的更成功的代码:

OK I got it to return a value in my listbox with the following code but with 6 and 5 put in for var1 and var2 respectively I get a zero in the list box. Any ideas why commnd.Parameters["C"].Value is null? Could it be that ExecuteNonQuery is wrong for this??

Thanks

Here''s my new more successful code:

展开 | 选择 | Wrap | 行号


我在你的第一篇文章中注意到,你首先将return参数添加到参数集合中,但你错误地标记了它作为ParameterDirection.Output。


在第二篇文章中,您将其正确标记为ParameterDirection.ReturnValue,但最后将其添加到集合中。


我相信MSDN声明ReturnValu e参数总是需要首先添加到ParameterCollection中,所以再试一次。


另外,没有看到你的实际存储过程,确保它确实是一个ReturnValue而不是输出参数。


例如,在SqlServer中,sqlRETURN返回一个ReturnValue。声明。

在过程定义中声明输出参数,并在过程中填充参数。可能有也可能没有RETURN语句,但它与输出参数无关。


另外,至少SqlServer,成功时隐式返回值为0,无论你是否声明或不声明,这样可以解释为什么你的文本框中有0。
I noticed in your first post, you added the return parameter to the parameter collection first, but you tagged it incorrectly as ParameterDirection.Output.

In the second post, you tagged it correctly as ParameterDirection.ReturnValue, but you add it to the collection last.

I believe MSDN states that ReturnValue parameters always need to be added to the ParameterCollection first, so try that again.

Also, not seeing your actual stored procedure, make sure it is indeed a ReturnValue and not an output paramater.

In SqlServer, for example, a ReturnValue is returned by the sql "RETURN" statement.
An output parameter is declared in the procedure definition, and the parameter is filled during the procedure. There may or may not also be a RETURN statement, but it is unrelated to the output parameter.

Also, SqlServer at least, has an implicit return value of 0 when successful, whether you declare it or not, so that may explain why you get a 0 in your text box.


您好,感谢您的回复。你是对的,它是一个输出参数。当我做出改变时,我仍然只得到0。


我不理解你的最后一段关于0成功后返回的内容。


我在服务器上看了一下,还有另一个名为AdditionParams的对象,在那里我找到了每个参数的所有属性,并且它们的值有一个位置。看起来Addition proc可能会查找该对象的A和B值并返回那里的C值?


知道了,我该如何处理?写入AdditionParams对象,运行没有添加参数的proc并读取C值???


感谢您的帮助。
Hi and thank you for your response. You are right it was an Output Parameter. I still only get a 0 when I make that change though.

I''m not understanding your last paragraph about 0 being returned when successful.

I had a look around on the server and there is another object called AdditionParams where I found all the attribute of each parameter and there is a place for their value. It looks like the Addition proc might look to that object for the A and B values and return the C value there??

Knowing that, how would I approach this? Write to the AdditionParams object, run the proc with no added params and read the C value???

Thanks for your help.


这篇关于OleDb存储过程调用问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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