Oracle.Connection 的替代品是什么?

发布于 2024-11-03 06:19:07 字数 462 浏览 8 评论 0原文

我有一个 vb.net 程序失败,但没有给出错误。我刚刚发现我正在使用的代码已被弃用。但替代是什么? (这对于 MSDN 来说似乎是有用的,但我确信没有看到它。)

Private Sub SetConnectionToDB(ByRef oCMD As OracleCommand)
    Dim connectionString As String
    connectionString = My.Settings.ImportDataConnectionString
    Dim OraDBConnection As OracleConnection
    OraDBConnection = New OracleConnection(connectionString)

    oCMD.Connection = OraDBConnection
    oCMD.CommandType = CommandType.Text
End Sub

I have a vb.net program that is failing, but giving no errors. I've just discovered that the code I am using is deprecated. But what is the replacment? (That seems like something useful for MSDN to list, but I'm sure not seeing it.)

Private Sub SetConnectionToDB(ByRef oCMD As OracleCommand)
    Dim connectionString As String
    connectionString = My.Settings.ImportDataConnectionString
    Dim OraDBConnection As OracleConnection
    OraDBConnection = New OracleConnection(connectionString)

    oCMD.Connection = OraDBConnection
    oCMD.CommandType = CommandType.Text
End Sub

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

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

发布评论

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

评论(3

救星 2024-11-10 06:19:08

如果有人需要详细说明,以下是我为另一位开发人员创建的步骤(我们使用 C# 进行开发,而不是 vb.net)。请注意,这是一个简单的迁移。

Oracle 指南:http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/hol08/dotnet/getstarted-c/getstarted_c_otn.htm

我创建/遵循了以下步骤:

  • 下载 Oracle 开发工具的链接:http://www.oracle。 com/technology/software/tech/windows/odpnet/index.html。 (您可能需要创建一个帐户)。然后单击“Downloads”并下载“32-bit ODAC with Oracle Developer Tools for Visual Studio Downloads”(如果需要,显然可以单击“64-bit...”链接)
  • 下载:\Downloads\ODTwithODAC121021.zip。
  • 打开 Zip 并将内容复制到任意位置。 (有一个setup.exe)
  • 运行“setup.exe”
  • 安装说明(如果需要):http://www.oracle。 com/technetwork/topics/dotnet/downloads/install121021-2389380.html
  • 安装时我使用了所有默认值。
  • 注意:安装在 64% 时挂起(…生成…exe…),但它最终还是自行继续。
  • 我复制了安装完成时显示的注释以供参考。以“运行位于...的 SQL 脚本”开头
  • 在发生数据访问的类中,添加:
    使用 Oracle.DataAccess.Client;
    使用 Oracle.DataAccess.Types;
  • 您将得到:“找不到类型或命名空间‘Oracle’(您是否缺少指令或程序集引用?)”
  • 右键单击项目:添加/引用:程序集/扩展:Oracle.DataAccess 版本 4.121.2.0
  • 注释掉现有的: //using System.Data.OracleClient; (否则您将收到“OracleConnection 是一个不明确的引用”错误。)

  • 我什至不需要修改现有的代码,例如:
  • Conn = new OracleConnection(connectionString);

    In case anyone needs this spelled out, here are the steps I created for another developer (we are developing using C#, not vb.net). Note that this was an easy migration.

    The Oracle guide: http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/hol08/dotnet/getstarted-c/getstarted_c_otn.htm.

    I created/followed these steps:

  • Link to download Oracle Developer Tools: http://www.oracle.com/technology/software/tech/windows/odpnet/index.html. (You might need to create an account). Then click “Downloads” and download “32-bit ODAC with Oracle Developer Tools for Visual Studio Downloads” (obviously click the “64-bit…” link if needed)
  • That downloads: \Downloads\ODTwithODAC121021.zip.
  • Open the Zip and copy the contents to any location. (has a setup.exe)
  • Run the “setup.exe”
  • Installation instructions (if needed): http://www.oracle.com/technetwork/topics/dotnet/downloads/install121021-2389380.html
  • When installing I used all default values.
  • Note: Installation hung at 64% (…spawning…exe…) but it did eventually continue on its own.
  • I copied for reference their note presented when the install completed. Starts with "Run the SQL scripts located in..."
  • In your class where data access occurs, add:
    using Oracle.DataAccess.Client;
    using Oracle.DataAccess.Types;
  • You’ll get: “The type or namespace ‘Oracle’ could not be found (are you missing a directive or assembly reference?)”
  • Right click the project: Add/reference: Assemblies/Extensions: Oracle.DataAccess Version 4.121.2.0
  • Comment out the existing: //using System.Data.OracleClient; (Or else you’ll get an “OracleConnection is an ambiguous reference” error.)

  • I didn't even need to modify my existing code, e.g.:
  • Conn = new OracleConnection(connectionString);

    忘羡 2024-11-10 06:19:08

    msdn 页面 指出

    此类型已弃用,并将
    在未来版本中删除
    .NET框架。欲了解更多信息,
    请参阅 Oracle 和 ADO.NET。

    Oracle 和 ADO.NET 状态

    System.Data.OracleClient 中的类型
    已弃用。类型有
    .NET 版本 4 支持
    框架,但将在
    未来的版本。微软推荐
    您使用第三方 Oracle
    提供商。

    This msdn page states that

    This type is deprecated and will be
    removed in a future version of the
    .NET Framework. For more information,
    see Oracle and ADO.NET.

    Oracle and ADO.NET states

    The types in System.Data.OracleClient
    are deprecated. The types are
    supported in version 4 of the .NET
    Framework but will be removed in a
    future release. Microsoft recommends
    that you use a third-party Oracle
    provider.

    月依秋水 2024-11-10 06:19:08

    我知道很久以前就有人问过(并回答过)这个问题,但如果其他人刚刚发现这一点,我个人建议使用 适用于 .NET 的 Oracle 数据提供程序

    I know this was asked (and answered) a long time ago, but in case anyone else is just discovering this, I personally recommend using Oracle Data Provider for .NET.

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