.NET ODBC Oracle Params 获取数据库提供程序返回的参数名称 - 可能吗?
我正在将一些 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,ODBC 中的参数是位置参数,而不是名称参数。
No, parameters in ODBC are positional not by name.