官方下载地址(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();

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

 

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

C#连接Oracle数据库的方法(System.Data.OracleClient、Oracle.DataAccess.Client也叫ODP.net、Oracle.ManagedDataAccess.dll)的更多相关文章

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

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

  2. Reporting Services无法连接ORACLE,提示:System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或更高版本

    Reporting Services无法连接ORACLE,在服务器安装ORACLE 11客户端版本后仍然提示以下错误: System.Data.OracleClient 需要 Oracle 客户端软件 ...

  3. asp.net 连接oracle,报错误“System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或更高版本

    1.http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html 下载对用版本的Instan ...

  4. [C#.Net]C#连接Oracle数据库的方法

    首先介绍下开发环境:WIn10 64bit+Visual Studio 2015+Oracle10ClientWin32(只是客户端,如果安装整个数据库也是可以的) 目前了解C#中连接Oracle数据 ...

  5. C#连接Oracle数据库的方法

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

  6. C#连接各种数据库的方法(文档)

    1.C#连接连接Access程序代码: ------------------------------------------------------------------------------- ...

  7. oracleclient连oracle库 报System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或更高版本

    在iis下发布eworkflow+eform+ebiao的代码,访问oracle的数据库,用oracleClient或者oledb的方式连接,有时会报“System.Data.OracleClient ...

  8. 微軟将从 .NET 4 以后的版本弃用 System.Data.OracleClient 以及Oracle 的各种连接方法

    这是微软官方 ADO.NET Team Blog 去年就公布的消息: http://blogs.msdn.com/adonet/archive/2009/06/15/system-data-oracl ...

  9. C# VS2010中,用微软自带的System.Data.OracleClient来连接Oracle数据库

    由于微软在.Net框架4.0中已经决定撤销使用System.Data.OracleClient,造成在VS2010中无法连接Oracle数据库,但它还依旧存在于.Net架构中,我们可以通过自己引用 C ...

随机推荐

  1. git游戏杂谈

    git作为一个知名小游戏,在被Linus开发出来后就广受好评,在程序员圈子内迅速传播,以至于现在很多程序员可以一日无饭,却不能一日无git.是什么能让各路程序员如此着迷?今天,让我们走进git,看一看 ...

  2. [bzoj2654]tree_二分_kruskal

    tree bzoj-2654 题目大意:给你一个无向带权连通图,每条边是黑色或白色.让你求一棵最小权的恰好有need条白色边的生成树.题目保证有解. 注释:$1\le V\le 5\cdot 10^4 ...

  3. 使用Visual Studio Code调试Electron主进程

    1.打开VS Code,使用文件->打开,打开程序目录 2.切换到调试选项卡 3.打开launch.json配置文件 4.在“附加到进程”节点上增加localhost配置 5.使用命令行启动el ...

  4. VC ON_CONTROL_RANGE多个控件响应一个方法

    步骤/方法 分三个步骤 在头文件里声明函数比如 afx_msg void onNum(UINT uID) 在.cpp文件里加入函数体 void CCalculatorDlg::OnNum(UINT u ...

  5. 【JavaScript】离开页面前提示

    离开页面前的提示不能够用onunload去做,由于它仅仅是兼容IE,你要兼容Google与FireFox就蛋疼了. 并且这个事件还是关闭之后才会触发的. 取而代之能够用onbeforeunload去实 ...

  6. Python游戏server开发日记(一)目标

    到了新的环境.老大让我有空研究下一代server技术,作为一个长期任务. 新的server想达到的目标: 1.分布式系统,对象(Entity)之间的关系类似于Actor模型. 2.逻辑服务,是单进程. ...

  7. canvas制作饼图和环形图,使用Excanvas兼容IE67

    excanvas 地址:http://excanvas.sourceforge.net/ <!DOCTYPE html> <html> <head> <met ...

  8. bzoj2935 [Poi1999]原始生物——欧拉回路

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2935 考察欧拉回路性质的题目呢: TJ:https://blog.csdn.net/u014 ...

  9. Python开发利器PyCharm 2.7附注册码

    PyCharm 2.7 下载 http://download.jetbrains.com/python/pycharm-2.7.2.exe 激活注册 user name:EMBRACE key: 14 ...

  10. ie8 不支持 position:fixed 的简单解决办法

    今天发现使用 position:fixed 的页面在firefox下没有问题,在IE8下却不能正常显示,在网上找了找,有不少相关文章,但是不是不起作用就是太复杂,后来终于发现一个简单的解决办法,就是在 ...