官方下载地址(ODP.net)(中文):http://www.oracle.com/technetwork/cn/topics/dotnet/downloads/index.html

官方下载地址(ODP.net):http://www.oracle.com/technetwork/topics/dotnet/downloads/index.html

首先介绍下开发环境:WIn10 64bit+Visual Studio 2015+Oracle10ClientWin32(只是客户端,如果安装整个数据库也是可以的)

目前了解C#中连接Oracle数据库的方法有3种,分布是微软的System.Data.OracleClient,Oracle的Oracle.DataAccess.Client和Oracle的Oracle.ManagedDataAccess.dll(最优)

1.微软的System.Data.OracleClient可以直接引用,但是VS会提示“System.Data.OracleClient.OracleConnection”已过时,这表明微软自己都不建议使用了,所以知道就可以了,不必使用

2.C#使用Oracle.DataAccess.Client也叫ODP.net,他是Oracle提供的数据库访问类库,其功能和效率上都有所保证,它还有一个非常方便特性:在客户端上,可以不用安装Oracle客户端,直接拷贝即可使用。由于微软在.net framework4中会将System.Data.OracleClient.dll deprecated,而且就访问效率和速度而言,System.Data.OracleClient.dll与Oracle.DataAccess.dll相比,微软的确实没有oracle提供的类库有优势,所以我放弃了使用多年的System.Data.OracleClient.dll,取而代之的是odp.net。然而odp.net的优点不止这些,还包括:
1)不在安装客户端也能访问服务器上的oracle(假设Application Server与DB Server 分开)
2)不需要配置TnsNames.Ora文件

具体的使用方法请参考这位大侠的  http://blog.csdn.net/rrrrssss00/article/details/7178515/

还有这位大侠的 http://blog.csdn.net/sumirry/article/details/46746331

如果项目要从System.Data.OracleClient.OracleConnection转Oracle.DataAccess.Client时,只需要在oracle 安装目录下 找到 Oracle.DataAccess.dll添加引用,后 using Oracle.DataAccess.Client;
其他的都不用动,即可。
连接字符串中 如有 用的是 user=xxx 就改成user id=xxx把原来 Using 的System.Data.OracleClient去掉即可。

3.重点学习最后一种Oracle.ManagedDataAccess.dll,第二种的优点很多,但是也有缺点,就是要区分用区分x86/x64版本。

下载dll和使用方法参考这位大侠的 https://www.cnblogs.com/zouhao/p/9236947.html

            OracleConnection con = new OracleConnection(ConfigurationManager.ConnectionStrings["OracleConnString"].ToString());con.Open();OracleCommand cmd = new OracleCommand(cmdString, con);OracleDataAdapter oda = new OracleDataAdapter();oda.SelectCommand = cmd;oda.Fill(ds);GridView1.DataSource = ds;GridView1.DataBind();

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Oracle ODP.NET数据库访问连接字符串

 

Connection String Attribute

默认值

描述

Connection Lifetime

0

Maximum life time (in seconds) of the connection

当数据库连接被返回到连接池中时,它的创建时间将与当前时间比较,如果超过了 Connection Lifetime 规定的时间,它将被释放掉。 为 0 时将被视为最大连接时间。

Connection Timeout

15

Maximum time (in seconds) to wait for a free connection from the pool

Data Source

empty string

Oracle Net Service Name that identifies the database to connect to

DBA Privilege

empty string

Administrative privileges: SYSDBA or SYSOPER

Decr Pool Size

1

Controls the number of connections that are closed when an excessive amount of established connections are unused

Enlist

true

Enables or disables serviced components to automatically enlist in distributed transactions

当此值为 true 时,池中现存的所有数据库连接将被加入到它的创建线程的 Transaction Context 中。如果不存在这个 Transaction Context 则无任何变化。

Incr Pool Size

5

Controls the number of connections that are established when all the connections in the pool are used

Max Pool Size

100

Maximum number of connections in a  pool

Min Pool Size

1

Minimum number of connections in a pool

Password

empty string

Password for the user specified by User Id

Persist Security Info

false

Enables or disables the retrieval of password in the connection string

Pooling

true

Enables or disables connection pooling

Proxy User Id

empty string

User name of the proxy user

Proxy Password

empty string

Password of the proxy user

User Id

empty string

Oracle user name

 

// C#

...

OracleConnection con = new OracleConnection();

con.ConnectionString = "User Id=scott;Password=tiger;Data Source=oracle;Pooling=true;Enlist=true;Min Pool Size=10;Connection Lifetime=120;Connection Timeout=60;Incr Pool Size=5; Decr Pool Size=2";

con.Open();

...

以下网站提供连接字符串大全:

www.ConnectionStrings.com

转载于:https://www.cnblogs.com/zouhao/p/9000286.html

C#连接Oracle数据库的方法(Oracle.DataAccess.Client也叫ODP.net)相关推荐

  1. 如何将sql数据导入到oracle数据库,将SQLServer的数据导入到Oracle数据库的方法-Oracle...

    1.首先在SQL Server的电脑上安装Oracle,或者是操作的电脑上安装Oracle,如果没有,导出时会提示失败 2.打开SQL Server,右键点击要导出的数据库,选择"任务&qu ...

  2. 用ASP.Net(C#)连接Oracle数据库的方法

    今天看了一下asp.net连接oracle数据库的方法,得到了如下代码.这段代码打开了MyTable表,并把操作员的名字列出.字段类型是OracleString.读取的时候用的是字段编号,我不知道怎么 ...

  3. .NET连接ORACLE数据库的方法

    .NET连接ORACLE数据库的方法就目前有3种: 1.OLEDB的方式,这种方式要求你要安装oracle client,这两年来做的关于oracle数据库的,我都采用这种方式,虽然连接的速度慢了一点 ...

  4. python连接oracle数据库的方法_Python3.6连接Oracle数据库的方法详解

    本文实例讲述了Python3.6连接Oracle数据库的方法.分享给大家供大家参考,具体如下: 下载cx_Oracle模块模块: https://pypi.python.org/pypi/cx_Ora ...

  5. LOADRUNNER连接ORACLE数据库的方法

    LOADRUNNER连接ORACLE数据库的方法 最近正在做一个测试数据库性能的项目,直接写出来的连接数据库并且进行数据库查询和插入的脚本 在VUSER_INIT中(连接数据库) #include & ...

  6. PLSQL Developer工具远程连接Oracle数据库的方法

    Oracle数据库安装过程较为繁琐,而且卸载更加麻烦,如果卸载不干净,下次安装Oracle就不会成功.下面就为大家介绍一种不用安装Oracle客户端而利用PLSQL Developer工具远程连接Or ...

  7. [导入]用ASP.Net(C#)连接Oracle数据库的方法

    用ASP.Net(C#)连接Oracle数据库的方法 文章来源:http://blog.csdn.net/21aspnet/archive/2004/12/10/211991.aspx 转载于:htt ...

  8. oracle 连接组件,[2021] node连接oracle数据库示例[使用oracle官方组件]

    [2021] node连接oracle数据库示例[使用oracle官方组件] node 连接 oracle 示例 本示例采用的 oracledb 和 instantclient-basic-windo ...

  9. oracle数据库配置环境,win7环境下配置oracle数据库的方法

    前些日子在在Win7下安装了oracle 11g,不过PL/SQL却没法用,在实验的过程中,遇到了很多问题,下面就教您win7环境下配置oracle数据库的方法,供您参考. 环境:Windows 7( ...

最新文章

  1. 【mybatis学习记录】mybatis的各种查询 一对一关联查询(4种方式) 一对多(2种方式)
  2. php自定义中文分词方法,php实现的中文分词类完整实例
  3. 【李超树】李超线段树维护凸包(凸壳) (例题:blue mary开公司+线段游戏+ZZH的旅行)
  4. 使用indexOf()算出长字符串中包含多少个短字符串
  5. nginx_keepalived配置(转载保存)
  6. 分析一个文本文件(英文文章)中各个词出现的频率,并且把频率最高的十个词打印出来...
  7. uva 232 Crossword Answers
  8. PHP5.5+Nginx1.9
  9. LwIP协议栈之ARP(Address Resolution Protocal)协议详解
  10. 节后一起搞学习!聊一聊我在 B 站上自学编程的经历吧
  11. 英语单词记忆(词缀 / 后缀)
  12. Java|如何用Java定义一个类
  13. 如果你读不完凯文凯利的《必然》,至少读完这120条书摘
  14. 一般二阶线性非齐次微分方程的解与对应齐次方程的解的关系
  15. 解压缩报错tar: Error is not recoverable: exiting now
  16. 职称计算机考试演示,2015职称计算机考试模拟题:演示文稿的放映、打包和打印...
  17. 本科毕业论文参考文献可以随便写吗?
  18. 【融职培训】Web前端学习 第3章 JavaScript基础教程9 内置对象
  19. 华为云发布代码检查服务;微软向其美国雇员提供“无限制”休假时间;付费版 ChatGPT|极客头条
  20. linux系统--文件目录

热门文章

  1. Test tape drive on Command Line
  2. java等待欢迎界面_android welcome欢迎界面3秒后自动跳转
  3. matlab把cell矩阵转换成能处理的数据
  4. SDR、DDR、QDR存储器的比较
  5. 用Tcl定制Vivado设计实现流程
  6. python升级和安装pip
  7. 图像篡改检测pytorch版本
  8. 模型压缩的开源项目工具
  9. python 习题集锦
  10. 看板中的WIP限制思想 1