C#连接Oracle数据库的方法(Oracle.DataAccess.Client也叫ODP.net)
官方下载地址(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();
...
以下网站提供连接字符串大全:
C#连接Oracle数据库的方法(Oracle.DataAccess.Client也叫ODP.net)的更多相关文章
- C#连接Oracle数据库的方法(System.Data.OracleClient、Oracle.DataAccess.Client也叫ODP.net、Oracle.ManagedDataAccess.dll)
官方下载地址(ODP.net)(中文):http://www.oracle.com/technetwork/cn/topics/dotnet/downloads/index.html 官方下载地址(O ...
- [C#.Net]C#连接Oracle数据库的方法
首先介绍下开发环境:WIn10 64bit+Visual Studio 2015+Oracle10ClientWin32(只是客户端,如果安装整个数据库也是可以的) 目前了解C#中连接Oracle数据 ...
- C#连接Oracle数据库的方法
目前了解C#中连接Oracle数据库的方法有3种,分布是微软的System.Data.OracleClient,Oracle的Oracle.DataAccess.Client和Oracle的Oracl ...
- .net远程连接oracle数据库不用安装oracle客户端的方法
.net远程连接oracle数据库不用安装oracle客户端的方法步骤: 1.添加Sytem.Data.OracleClient命名空间. 2.连接时需要ConnectionString字符串,出现在 ...
- JDBC连接各种数据库的方法,连接MySql,Oracle数据库
JDBC连接各种数据库的方法: JDBC编程步骤: 1.导入jar包 2.注册驱动 3.获取数据库连接对象 4.定义SQL语句 5.获得执行SQL语句对象statemnet 6.执行SQL语句 7.处 ...
- LOADRUNNER连接ORACLE数据库的方法
LOADRUNNER连接ORACLE数据库的方法 最近正在做一个测试数据库性能的项目,直接写出来的连接数据库并且进行数据库查询和插入的脚本在VUSER_INIT中(连接数据库)#include ...
- 用ASP.Net(C#)连接Oracle数据库的方法及实例
今天看了一下asp.net连接oracle数据库的方法,得到了如下代码.这段代码打开了MyTable表,并把操作员的名字列出.字段类型是OracleString.读取的时候用的是字段编号,我不知道怎么 ...
- .net远程连接oracle数据库不用安装oracle客户端
asp.net远程连接oracle数据库不用安装oracle客户端的方法下面是asp.net连接远程Oracle数据库服务器步骤: 1.asp.net连接oracle服务器需要添加Sytem.Data ...
- phalcon: 解决php7/phalcon3.2以上版本,不支持oracle数据库的方法
解决php7/phalcon3.2以上版本,不支持oracle数据库的方法 phalcon3.2(3.0以上)版本不支持oracle的方法. https://github.com/phalcon/in ...
随机推荐
- POJ 1008 简单模拟题
e.... 虽然这是一道灰常简单的模拟题.但是米做的时候没有读懂第二个日历的计时方法.然后捏.敲完之后华丽的WA了进一个点.坑点就在一年的最后一天你是该输出本年的.e ...但是我好想并没有..看di ...
- jsonp 遍历文档
遍历文档 将html解析成一个Document后,就可以使用类似Dom的方法进行操作 File input = new File("/tmp/input.html"); Docum ...
- 51nod1210
题解: 二维树状数组,再矩阵推一下 代码: #include<bits/stdc++.h> using namespace std; typedef long long LL; ; int ...
- 玩转X-CTR100 l STM32F4 l OLED显示-SSD1306无字库
我造轮子,你造车,创客一起造起来!塔克创新资讯[塔克社区 www.xtark.cn ][塔克博客 www.cnblogs.com/xtark/ ] OLED显示屏具有自发光特性,不需要背光, ...
- CUDA ---- Constant Memory
CONSTANT MEMORY constant Memory对于device来说只读但是对于host是可读可写.constant Memory和global Memory一样都位于DRAM,并且有 ...
- 太完美 TWM000极度精简版XP20130123终结美化版
TWM000极度精简版XP20130123终结美化版:蛋蛋20130123终结版为蓝本,虫子提供的美化包进行了美化.此版经测试完美在Z77主板开启AHCI安装,此为最终版之美化版!LiteXPMH.i ...
- 增量打包DOC版
压缩zip的命令有的系统没有的自己去下载一个,否则关闭压缩zip的命令. 有需要的自行更改,这是满足我需求的. 执行 publish.bat 即可,当然需要将文件清单写好放在 resources.tx ...
- 解决Viewpager满屏不能自适应填充内容的三种办法
由于排版问题,本人博客园同名博文地址为:http://www.cnblogs.com/bill-technology/articles/3143667.html 很多Android开发者在使用View ...
- 成为java高级程序员需要掌握哪些
section 1 1.Core Java,就是Java基础.JDK的类库,很多童鞋都会说,JDK我懂,但是懂还不足够,知其然还要知其所以然,JDK的源代码写的非常好,要经常查看,对使用频繁的类,比如 ...
- 一个两年Java的面试总结
前言 16年毕业到现在也近两年了,最近面试了阿里集团(菜鸟网络,蚂蚁金服),网易,滴滴,点我达,最终收到点我达,网易offer,蚂蚁金服二面挂掉,菜鸟网络一个月了还在流程中...最终有幸去了网易.但是 ...