惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Help Net Security
Help Net Security
G
Google Developers Blog
雷峰网
雷峰网
WordPress大学
WordPress大学
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Engineering at Meta
Engineering at Meta
Security Latest
Security Latest
T
Threat Research - Cisco Blogs
AWS News Blog
AWS News Blog
F
Full Disclosure
C
Cybersecurity and Infrastructure Security Agency CISA
T
The Exploit Database - CXSecurity.com
J
Java Code Geeks
U
Unit 42
C
Cyber Attacks, Cyber Crime and Cyber Security
V
V2EX
C
Cisco Blogs
博客园 - 司徒正美
Project Zero
Project Zero
L
LINUX DO - 热门话题
阮一峰的网络日志
阮一峰的网络日志
Blog — PlanetScale
Blog — PlanetScale
Scott Helme
Scott Helme
A
About on SuperTechFans
Hugging Face - Blog
Hugging Face - Blog
S
Securelist
小众软件
小众软件
aimingoo的专栏
aimingoo的专栏
S
Schneier on Security
G
GRAHAM CLULEY
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyberwarzone
Cyberwarzone
MongoDB | Blog
MongoDB | Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 叶小钗
T
Threatpost
Recorded Future
Recorded Future
C
CXSECURITY Database RSS Feed - CXSecurity.com
宝玉的分享
宝玉的分享
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
The Register - Security
The Register - Security
S
Security Archives - TechRepublic
博客园 - Franky
N
News | PayPal Newsroom
Simon Willison's Weblog
Simon Willison's Weblog
S
SegmentFault 最新的问题
W
WeLiveSecurity
A
Arctic Wolf
B
Blog

博客园 - lsyyx

SQL Server 2008中SQL增强之三:Merge(在一条语句中使用Insert,Update,Delete) SQL Server 2008中SQL增强之二:Top新用途 SQL Server 2008中SQL增强之一:Values新用途 SQL Server 2008中增强的汇总技巧 需要弥补的那部分SQL oracle递归查询\sqlserver递归 - lsyyx - 博客园 如何写SQL,计算上下记录同一字段相差值 SQL语句整理资料 Sqlserver Update 用法 可判断datatable的列是否有重复 Asp.Net4.0/VS2010新变化(4):SEO的改进 Asp.Net4.0/VS2010新变化(2):网站自动预热 Asp.Net4.0/VS2010新变化(3):webform中也可以直接url路由 NET4.0中非常好用的一个东西Tuple 关于.net4.0中的Action委托 NET4.0多线程编程---Tasks .NET4.0多线程编程---Cooperative Cancellation net4.0新特性之线程同步 C#4.0语言新功能及应用 (1)
Oracle:ODP.NET Managed 小试牛刀 (转)
lsyyx · 2014-10-23 · via 博客园 - lsyyx

“ODP.NET Managed”发布已经有一段时间了,近期正好有一个新项目,想尝试用一下,参考园子里的文章:《.NET Oracle Developer的福音——ODP.NET Managed正式推出》 到Oracle官网 下载 ODP.NET_Managed121010.zip 大约1.9M,解压后目录结构如下:

核心的dll,就是common目录下的Oracle.ManagedDataAccess.dll,不象ODP.NET以前的版本,这次终于不用区分x86/x64版本了,不管是32位还是64位,都是同一个dll。

至于manged/x64、managed/x86这二个目录,是用来向.NET x86或.NET x64的GAC注册程序集的,运行相关的configure.bat后,会自动将common中的Oracle.ManagedDataAccess.dll放入GAC,这样在vs中添加引用时,能自动找到GAC中的相关命名空间

运行了configure.bat的机器上,应用程序的bin目录下不必包括Oracle.ManagedDataAccess.dll,就能正常运行了。

注:configure.bat这一步是可选的,添加引用时,完全也可以通过直接浏览Oracle.ManagedDataAccess.dll所在位置,将该dll复制到bin目录下.

下面是最基本的使用代码:

复制代码

 1 using System;
 2 using System.Data;
 3 using Oracle.ManagedDataAccess.Client;
 4 
 5 namespace ODP.NET
 6 {
 7     class Program
 8     {
 9         static void Main(string[] args)
10         {
11             OracleConnection conn = null;
12             try
13             {
14                 conn = OpenConn();
15                 var cmd = conn.CreateCommand();
16                 cmd.CommandText = "select * from s_awb_master where rownum=1";
17                 cmd.CommandType = CommandType.Text;
18                 var reader = cmd.ExecuteReader();
19                 while (reader.Read())
20                 {
21                     Console.WriteLine(string.Format("AwbPre:{0},AwbNo:{1}", reader["AwbPre"], reader["AwbNo"]));
22                 }
23             }
24             catch (Exception ex)
25             {
26                 Console.WriteLine(ex.Message);
27             }
28             finally
29             {
30                 CloseConn(conn);
31             }
32             Console.Read();
33         }
34 
35 
36         static OracleConnection OpenConn()
37         {
38             OracleConnection conn = new OracleConnection();
39             conn.ConnectionString = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=***.***.***.***)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=***)));Persist Security Info=True;User ID=***;Password=***;";
40             conn.Open();
41             return conn;
42         }
43 
44         static void CloseConn(OracleConnection conn)
45         {
46             if (conn == null) { return; }
47             try
48             {
49                 if (conn.State != ConnectionState.Closed)
50                 {
51                     conn.Close();
52                 }
53             }
54             catch (Exception e)
55             {
56                 Console.WriteLine(e.Message);
57             }
58             finally
59             {
60                 conn.Dispose();
61             }
62         }
63     }
64 }

复制代码

最后附上dll下载:https://files.cnblogs.com/yjmyzz/Oracle.ManagedDataAccess.zip