.NET ODBC Oracle Params 获取数据库提供程序返回的参数名称 - 可能吗?

发布于 2024-09-28 09:44:27 字数 695 浏览 0 评论 0原文

我正在将一些 RDO 代码转换为 .NET 中的 ODBC 提供程序代码。

问题是原始代码中没有指定参数名称,但命令执行后通过参数名称检索参数值。

执行命令后,是否有提供程序填充参数名称,以便调用代码可以按名称访问参数。

让我向您展示一个声明 param 和访问它的示例。

    With rdqryClntBasic
        .Parameters.Add(.CreateParameter) : .Parameters(0).Direction = ParameterDirection.Input
        .Parameters(0).DbType = DbType.String
        .Parameters(0).Value = sClntProdCd

End With

.EffectiveDate = ToDate(rdqryClntBasic.Parameters("dtEffDt").Value)

您现在可以看到它“如何在 RDO/VB 中工作”。由于某种原因它会接受这个并知道执行后参数名称是什么。我想它必须再次往返数据库才能获取此信息。

无论如何,有没有办法在.NET for ODBC Provider(使用Oracle)中模仿这种行为?或者我是否坚持在代码中手动指定参数名称(我知道这是更好的选择,但想知道有什么替代方案可以尽可能接近地匹配原始代码)。

I'm converting some RDO code to ODBC Provider code in .NET.

The problem is parameter names were not specified in the orignal code, but param values were retrieved by parameter name after the command was executed.

Is there anyway to have parameter names populated by the provider once the command is executed so calling code can access params by name.

Let me show you an example of the declaration of param and accessing of it.

    With rdqryClntBasic
        .Parameters.Add(.CreateParameter) : .Parameters(0).Direction = ParameterDirection.Input
        .Parameters(0).DbType = DbType.String
        .Parameters(0).Value = sClntProdCd

End With

.EffectiveDate = ToDate(rdqryClntBasic.Parameters("dtEffDt").Value)

You can now see how this "used to work in RDO/VB". For some reason it would accept this and know what the param names were after execution. I imagine it had to do another round trip to the db to get this info.

Is there anyway to mimic this behaviour in .NET for ODBC Provider (using Oracle)? Or am I stuck manually specifying the param names in the code (I understand this is the better option, but wondering what the alternative is to match the original code as closely as possible).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

┈┾☆殇 2024-10-05 09:44:28

不,ODBC 中的参数是位置参数,而不是名称参数。

No, parameters in ODBC are positional not by name.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文