【问题标题】:How I include oracle client in my code我如何在我的代码中包含 oracle 客户端
【发布时间】:2014-06-25 21:17:28
【问题描述】:

我在 App_Code 中有一个 DAL.CS 类。我正在使用 oracle 数据库。我还在 Refrence 文件夹中添加了 OracleClient refrence,但出现以下错误 CS0234:命名空间“System.Data”中不存在类型或命名空间名称“OracleClient”(您是否缺少程序集引用?)。我如何解决此问题

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Data;
using System.Data.OracleClient;


     namespace SchoolsManagementSystem
    {
      public class DAL
      {
        string CS = ConfigurationManager.ConnectionStrings["Oracleconnect"].ConnectionString;
        private OracleConnection GetConnection()
        {
            var conString =       System.Configuration.ConfigurationManager.ConnectionStrings["Oracleconnect"];
            string strConnString = conString.ConnectionString;
            return new OracleConnection(strConnString);
        }
        public string AunthicateUser(string username, string password)
        {
            using (OracleConnection con = GetConnection())
            {
                OracleCommand cmd = new OracleCommand("SELECT * FROM AuthenticateUser(@UserName, @Password)", con);

                cmd.Parameters.AddWithValue("@UserName", "username");
                cmd.Parameters.AddWithValue("@Password", "password");

                OracleDataAdapter da = new OracleDataAdapter(cmd);

                DataTable dt = new DataTable();
                da.Fill(dt);

                string str = dt.Rows[0][0].ToString();
               // Response.Write(str.ToString());

                return str;
            }
        }

    }
  }

以下错误是什么意思。我添加了Oracle客户端的引用。 源错误: 第 5 行:使用 System.Configuration; 第 6 行:使用 System.Data; 第 7 行:使用 System.Data.OracleClient; 第 8 行:
第 9 行:

Source File: d:\c#\SchoolsManagementSystem\SchoolsManagementSystem\App_Code\DAL.cs    Line: 7 

【问题讨论】:

    标签: c# asp.net oracle linq ado.net


    【解决方案1】:

    不要使用 Microsoft Oracle 客户端。甚至微软也说不要使用它。使用 Oracle 的 ODP.net 或 devArt dotConnect(有免费版本)。 Microsoft 驱动程序在 .NET 2.0 之后被删除,这是有充分理由的。

    http://www.oracle.com/technetwork/topics/dotnet/index-085163.html

    您的大部分代码不会改变。

    【讨论】:

    • 安装 ODP.net 后我使用了什么命名空间?我的意思是 ODP.OracleClient
    • 使用Oracle.DataAccess.Client;
    【解决方案2】:

    我在我的电脑上找到了“System.Data.OracleClient.dll”:

    C:\Windows\Microsoft.NET\Framework\v4.0.30319

    我已经通过浏览 DLL 添加了引用,所有编译器错误都消失了,我可以启动程序了。

    但 Visual Studio 会发出警告:

    'System.Data.OracleClient.OracleConnection' ist veraltet: 'OracleConnection 已被弃用。

    http://go.microsoft.com/fwlink/?LinkID=144260'

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-23
      • 1970-01-01
      • 2018-06-07
      • 1970-01-01
      相关资源
      最近更新 更多