微軟将弃用

By admin in 4858.com on 2019年4月12日

4858.com 1

4858.com 2

消除办法如下:

微軟将从 .NET 4 未来的版本弃用 System.Data.OracleClient。

ODP.NET:

ODP.NET:

一.把本来的using System.Data.OracleClient;去掉

那是微软官方 ADO.NET Team Blog 2018年就公布的消息:

引用:

引用:

二.在oracle设置目录下找到Oracle.DataAccess.dll
添加引用:using Oracle.DataAccess.Client;

本人刚用 VS 20拾 测试了须臾间,才承认那项新闻的不错。OracleClient
是微软针对 Oracle 开发所研究开发的 ADO.NET Data Provider,从 .NET 1.x
开头,就已成为 .NET Framework 类库的一片段,它与微软 Visual Studio
的集成性卓殊好。

using Oracle.DataAccess; //Oracle g 11.2.0
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
//下载 http://www.oracle.com/technetwork/topics/dotnet/downloads/net-downloads-160392.html
//引用:D:\app\geovindu\product\11.2.0\dbhome_1\ODP.NET\bin
//用法参考
//
//http://docs.oracle.com/cd/B28359_01/appdev.111/b28844/procedures_dot_net.htm
//http://docs.oracle.com/cd/B19306_01/win.102/b14307/OracleDataAdapterClass.htm //.net 4.0
//https://docs.oracle.com/cd/B19306_01/server.102/b14220/schema.htm
using Oracle.DataAccess; //Oracle g 11.2.0
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
//下载 http://www.oracle.com/technetwork/topics/dotnet/downloads/net-downloads-160392.html
//引用:D:\app\geovindu\product\11.2.0\dbhome_1\ODP.NET\bin
//用法参考
//
//http://docs.oracle.com/cd/B28359_01/appdev.111/b28844/procedures_dot_net.htm
//http://docs.oracle.com/cd/B19306_01/win.102/b14307/OracleDataAdapterClass.htm //.net 4.0
//https://docs.oracle.com/cd/B19306_01/server.102/b14220/schema.htm

如若设置的是oracle 十g,那么在Visual Studio中并未有注册dll,添加引用时找不到,1壹g的默许是注册的。

该篇博文内容大体是说,微软前途不再帮助 System.Data.OracleClient 那些Data Provider 的研究开发,从 .NET 肆 以往的本子,会将此类库移除 [1]。由此,就算今后System.Data.OracleClient 在 VS 20拾 / .NET 四里仍可接纳,但在开发和编写翻译时,会并发多量的「deprecated
(不建议采用)」警告,如下图 一。

  数据库连接字符串:

  数据库连接字符串:

能够由此Windows自带的文件搜索效果到oracle安装目录里面去找,

基于 ADO.NET OracleClient 产品CEO Himanshu Vasishth
的传道,那对大家现有的品类和代码未有其他影响,大家仍可继续用
OracleClient 来开发应用程序,但 ADO.NET Team
强烈建议用户和开发人士,改用此外厂商或第三方供应商的 Oracle provider。

 public string connectionString = @"DATA SOURCE=oracle11g;USER ID=geovin;password=geovindu;";
 public string connectionString = @"DATA SOURCE=oracle11g;USER ID=geovin;password=geovindu;";

提示:若oracle安装在D盘根目录,则dll文件的途径如下

前景微软对小编的
System.Data.OracleClient,不会再推出新功效,只会指向重大难点和 bug
做勘误,并会继续将那几个改良发布在 .NET Framework 4.0 的 service packs。另
System.Data.OracleClient 三.5 的支撑会从 20一3 年延长到 201八年,System.Data.OracleClient 肆.0 的援救则与 .NET Framework 四.0
的生命周期相同。

  

  

D:\oracle\product\10.2.0\client_1\ODP.NET\bin\1.x(客户端)

4858.com 3
图 壹 以 Visual Studio 20拾Ultimate 中华VC 版 / .NET 四 项目测试,开发和编写翻译时会出现大批量的
Warning

/// <summary>
    /// 20160918 涂聚文
    /// Geovin Du
    /// </summary>
    public class BookKindListDAL : IBookKindList
    {

        ///<summary>
        /// 追加记录
        ///</summary>
        ///<param name="BookKindListInfo"></param>
        ///<returns></returns>
        public int InsertBookKindList(BookKindListInfo bookKindList)
        {
            int ret = 0;
            try
            {
                OracleParameter[] par = new OracleParameter[]{
    new OracleParameter("temTypeName",OracleDbType.NVarchar2,1000),
    new OracleParameter("temParent",OracleDbType.Int32,4),
    };
                par[0].Value = bookKindList.BookKindName;
                par[1].Value = bookKindList.BookKindParent;
                ret = OracleHelper.ExecuteSql("proc_Insert_BookKindList", CommandType.StoredProcedure, par);
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return ret;
        }
        /// <summary>
        /// 追加记录返回
        /// </summary>
        /// <param name="authorList"></param>
        /// <param name="authorID"></param>
        /// <returns></returns>
        public int InsertBookKindOutput(BookKindListInfo bookKindList, out int bookKindLID)
        {
            bookKindLID = 0;
            int ret = 0;
            try
            {
                OracleParameter[] par = new OracleParameter[]{
    new OracleParameter("temTypeName",OracleDbType.NVarchar2,1000),
                new OracleParameter("temParent",OracleDbType.Int32,4),
                new OracleParameter("temId",OracleDbType.Int32,4),
    };
                par[0].Value = bookKindList.BookKindName;
                par[1].Value = bookKindList.BookKindParent;
                par[2].Direction = ParameterDirection.Output;
                ret = OracleHelper.ExecuteSql("proc_Insert_BookKindOut", CommandType.StoredProcedure, par);
                if (ret > 0)
                {
                    bookKindLID =int.Parse(par[2].Value.ToString());
                }
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return ret;
        }
        ///<summary>
        ///修改记录
        ///</summary>
        ///<param name="BookKindListInfo"></param>
        ///<returns></returns>
        public int UpdateBookKindList(BookKindListInfo bookKindList)
        {
            int ret = 0;
            try
            {
                OracleParameter[] par = new OracleParameter[]{
    new OracleParameter("BookKindID",OracleDbType.Int32,4),
    new OracleParameter("BookKindName",OracleDbType.NVarchar2,1000),
    new OracleParameter("BookKindParent",OracleDbType.Int32,4),
    };
                par[0].Value = bookKindList.BookKindID;
                par[1].Value = bookKindList.BookKindName;
                par[2].Value = bookKindList.BookKindParent;
                ret = OracleHelper.ExecuteSql("proc_Update_BookKindList", CommandType.StoredProcedure, par);
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return ret;
        }
        ///<summary>
        /// 删除记录
        ///</summary>
        ///<param name="bookKindIDInfo"></param>
        ///<returns></returns>
        public bool DeleteBookKindList(int bookKindID)
        {
            bool ret = false;
            try
            {
                OracleParameter par = new OracleParameter("BookKindID", bookKindID);
                int temp = 0;
                temp = OracleHelper.ExecuteSql("proc_Delete_BookKindList", CommandType.StoredProcedure, par);
                if (temp != 0)
                {
                    ret = true;
                }
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return ret;
        }
        ///<summary>
        /// 查询记录
        ///</summary>
        ///<param name="bookKindIDInfo"></param>
        ///<returns></returns>
        public BookKindListInfo SelectBookKindList(int bookKindID)
        {
            BookKindListInfo bookKindList = null;
            try
            {
                OracleParameter par = new OracleParameter("BookKindID", bookKindID);
                using (OracleDataReader reader = OracleHelper.GetReader("proc_Select_BookKindList", CommandType.StoredProcedure, par))
                {
                    if (reader.Read())
                    {
                        bookKindList = new BookKindListInfo();
                        bookKindList.BookKindID = (!object.Equals(reader["BookKindID"], null)) ? (int)reader["BookKindID"] : 0;
                        bookKindList.BookKindName = (!object.Equals(reader["BookKindName"], null)) ? (string)reader["BookKindName"] : "";
                        bookKindList.BookKindParent = (!object.Equals(reader["BookKindParent"], null)) ? (int)reader["BookKindParent"] : 0;

                    }
                }
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return bookKindList;
        }

        ///<summary>
        /// 查询所有记录
        ///</summary>
        ///<returns></returns>
        public List<BookKindListInfo> SelectBookKindListAll()
        {
            List<BookKindListInfo> list = new List<BookKindListInfo>();
            BookKindListInfo bookKindList = null;
            try
            {
                using (OracleDataReader reader = OracleHelper.GetReader("proc_Select_BookKindListAll", CommandType.StoredProcedure, null))
                {
                    while (reader.Read())
                    {
                        bookKindList = new BookKindListInfo();
                        bookKindList.BookKindID = (!object.Equals(reader["BookKindID"], null)) ? (int)reader["BookKindID"] : 0;
                        bookKindList.BookKindName = (!object.Equals(reader["BookKindName"], null)) ? (string)reader["BookKindName"] : "";
                        bookKindList.BookKindParent = (!object.Equals(reader["BookKindParent"], null)) ? (int)reader["BookKindParent"] : 0;
                        list.Add(bookKindList);

                    }
                }
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return list;
        }
        ///<summary>
        /// 查询所有记录
        ///</summary>
        ///<returns></returns>
        public DataTable SelectBookKindListDataTableAll()
        {
            DataTable dt = new DataTable();
            try
            {
                using (DataTable reader = OracleHelper.GetTable("proc_Select_BookKindListAll", CommandType.StoredProcedure, null))
                {
                    dt = reader;


                }
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return dt;
        }

    }
/// <summary>
    /// 20160918 涂聚文
    /// Geovin Du
    /// </summary>
    public class BookKindListDAL : IBookKindList
    {

        ///<summary>
        /// 追加记录
        ///</summary>
        ///<param name="BookKindListInfo"></param>
        ///<returns></returns>
        public int InsertBookKindList(BookKindListInfo bookKindList)
        {
            int ret = 0;
            try
            {
                OracleParameter[] par = new OracleParameter[]{
                new OracleParameter("temTypeName",OracleDbType.NVarchar2,1000),
                new OracleParameter("temParent",OracleDbType.Int32,4),
                };
                par[0].Value = bookKindList.BookKindName;
                par[1].Value = bookKindList.BookKindParent;
                ret = OracleHelper.ExecuteSql("proc_Insert_BookKindList", CommandType.StoredProcedure, par);
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return ret;
        }
        /// <summary>
        /// 追加记录返回
        /// </summary>
        /// <param name="authorList"></param>
        /// <param name="authorID"></param>
        /// <returns></returns>
        public int InsertBookKindOutput(BookKindListInfo bookKindList, out int bookKindLID)
        {
            bookKindLID = 0;
            int ret = 0;
            try
            {
                OracleParameter[] par = new OracleParameter[]{
                new OracleParameter("temTypeName",OracleDbType.NVarchar2,1000),
                new OracleParameter("temParent",OracleDbType.Int32,4),
                new OracleParameter("temId",OracleDbType.Int32,4),
                };
                par[0].Value = bookKindList.BookKindName;
                par[1].Value = bookKindList.BookKindParent;
                par[2].Direction = ParameterDirection.Output;
                ret = OracleHelper.ExecuteSql("proc_Insert_BookKindOut", CommandType.StoredProcedure, par);
                if (ret > 0)
                {
                    bookKindLID =int.Parse(par[2].Value.ToString());
                }
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return ret;
        }
        ///<summary>
        ///修改记录
        ///</summary>
        ///<param name="BookKindListInfo"></param>
        ///<returns></returns>
        public int UpdateBookKindList(BookKindListInfo bookKindList)
        {
            int ret = 0;
            try
            {
                OracleParameter[] par = new OracleParameter[]{
                new OracleParameter("BookKindID",OracleDbType.Int32,4),
                new OracleParameter("BookKindName",OracleDbType.NVarchar2,1000),
                new OracleParameter("BookKindParent",OracleDbType.Int32,4),
                };
                par[0].Value = bookKindList.BookKindID;
                par[1].Value = bookKindList.BookKindName;
                par[2].Value = bookKindList.BookKindParent;
                ret = OracleHelper.ExecuteSql("proc_Update_BookKindList", CommandType.StoredProcedure, par);
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return ret;
        }
        ///<summary>
        /// 删除记录
        ///</summary>
        ///<param name="bookKindIDInfo"></param>
        ///<returns></returns>
        public bool DeleteBookKindList(int bookKindID)
        {
            bool ret = false;
            try
            {
                OracleParameter par = new OracleParameter("BookKindID", bookKindID);
                int temp = 0;
                temp = OracleHelper.ExecuteSql("proc_Delete_BookKindList", CommandType.StoredProcedure, par);
                if (temp != 0)
                {
                    ret = true;
                }
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return ret;
        }
        ///<summary>
        /// 查询记录
        ///</summary>
        ///<param name="bookKindIDInfo"></param>
        ///<returns></returns>
        public BookKindListInfo SelectBookKindList(int bookKindID)
        {
            BookKindListInfo bookKindList = null;
            try
            {
                OracleParameter par = new OracleParameter("BookKindID", bookKindID);
                using (OracleDataReader reader = OracleHelper.GetReader("proc_Select_BookKindList", CommandType.StoredProcedure, par))
                {
                    if (reader.Read())
                    {
                        bookKindList = new BookKindListInfo();
                        bookKindList.BookKindID = (!object.Equals(reader["BookKindID"], null)) ? (int)reader["BookKindID"] : 0;
                        bookKindList.BookKindName = (!object.Equals(reader["BookKindName"], null)) ? (string)reader["BookKindName"] : "";
                        bookKindList.BookKindParent = (!object.Equals(reader["BookKindParent"], null)) ? (int)reader["BookKindParent"] : 0;

                    }
                }
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return bookKindList;
        }

        ///<summary>
        /// 查询所有记录
        ///</summary>
        ///<returns></returns>
        public List<BookKindListInfo> SelectBookKindListAll()
        {
            List<BookKindListInfo> list = new List<BookKindListInfo>();
            BookKindListInfo bookKindList = null;
            try
            {
                using (OracleDataReader reader = OracleHelper.GetReader("proc_Select_BookKindListAll", CommandType.StoredProcedure, null))
                {
                    while (reader.Read())
                    {
                        bookKindList = new BookKindListInfo();
                        bookKindList.BookKindID = (!object.Equals(reader["BookKindID"], null)) ? (int)reader["BookKindID"] : 0;
                        bookKindList.BookKindName = (!object.Equals(reader["BookKindName"], null)) ? (string)reader["BookKindName"] : "";
                        bookKindList.BookKindParent = (!object.Equals(reader["BookKindParent"], null)) ? (int)reader["BookKindParent"] : 0;
                        list.Add(bookKindList);

                    }
                }
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return list;
        }
        ///<summary>
        /// 查询所有记录
        ///</summary>
        ///<returns></returns>
        public DataTable SelectBookKindListDataTableAll()
        {
            DataTable dt = new DataTable();
            try
            {
                using (DataTable reader = OracleHelper.GetTable("proc_Select_BookKindListAll", CommandType.StoredProcedure, null))
                {
                    dt = reader;


                }
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return dt;
        }

    }

D:\oracle\微軟将弃用。product\10.2.0\db_1\ODP.NET\bin\1.x(服务器)

以下是该文的持续研商中,所列出的1对 System.Data.OracleClient 替代方案:

  System.Data.OracleClient(.net 4.0)

  System.Data.OracleClient(.net 4.0)

3.连日字符串中如有用的是user=xxx就改成user id=xxx

  1. ODP.NET from Oracle:
    Oracle
    自家的缓解方案,正宗且永久免费,使用人口及技术社区广大,传闻品质比微软的
    Oracle driver 更优 (那一点未证实),但只提供基本的数量访问成效,不援助 ADO.NET Entity Framework。
    在 ODP.NET 10.二.0.肆 此前的本子,常被抱怨版本号码无法不与 Oracle
    数据库正确对应。但据他们说新的 ODP.NET 1壹g,已可与有着版本的 Oracle
    数据库包容 (包蕴 玖.二 版本),且在同三个操作系统上可安装几个版本。

  2. Devart dotConnet for Oracle:
    标准名称是 OraDirect.NET,可免费使用。可支撑 ADO.NET Entity
    Framework。

  3. DataDirect ADO.NET Data Provider for
    Oracle:
    可支持 ADO.NET Entity Framework。

  4. Oracle Multi-Tier .Net Provider from
    OPENLINK:

引用:

引用:

但就自个儿在网络上所看的,Oracle 自家的 ODP.NET,成效即使强劲,但与微软的
.NET / Visual Studio
集成性不算好。必须在每台要支付和配备的机器上,下载、安装、设置、维护
ODP.NET provider 和其 Oracle client libraries
(互连网上根本指其很难安装的抱怨文);且其 library 的本子,在 ODP.NET
拾.二.0.4 在此以前的本子,必须用对应版本的 Oracle ,像 Oracle 十g 就必须设置
⑩g ODP.NET,Oracle 玖i 就务须安装 九i ODP.NET
(这一点是该文的接续商讨事关的,小编未测试过,不显著是不是正确),而微软的
OracleClient
则无此难题,不必花时间安装和设置。且别的很重点的少数,ODP.NET
仍不扶助微软的 ADO.NET Entity Framework 和 LINQ to Entities (大概是
Oracle 的小购买销售策略)。

using System.Collections;
using System.Data;
using System.Configuration;
using System.Data.OracleClient;//.net 4.0

//用法参考
//https://msdn.microsoft.com/en-us/library/system.data.oracleclient.oracledataadapter(v=vs.110).aspx
//http://blog.csdn.net/chinawn/article/details/336904
//C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.OracleClient.dll
using System.Collections;
using System.Data;
using System.Configuration;
using System.Data.OracleClient;//.net 4.0

//用法参考
//https://msdn.microsoft.com/en-us/library/system.data.oracleclient.oracledataadapter(v=vs.110).aspx
//http://blog.csdn.net/chinawn/article/details/336904
//C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.OracleClient.dll

表面上看起来,是有极大比重的客户、MVPs
和开发职员,倾向用合作厂商或第贰方厂商的 Oracle provider,且因为 Oracle
数据库的改版和立异速度也十分的快,那一个第一方厂商能比较快地生产搭配 Oracle
数据库新作用的支撑。微软认为,自身无需再花财富和时间,追在 Oracle
的研究开发集团和第一方提供者的末端跑。

  数据库连接字符串:

  数据库连接字符串:

笔者自个儿则觉得,微软此举相对有战略意义,不见得像该博文所说的,只是为着节约从
.NET 到 Oracle
的版本控制或品质等研究开发能源。微软的目标之一,大概是想将他的客户,能从
Oracle 多拉1些回到。若客户的种类有例外部必要求、关键应用,或想用一些 .NET
访问数据库的一定语法和属性优化
[2],提议你用微软的 SQL Server;不然很对不起,倘使未来 .NET
肆.x、伍、陆、7、…平台有怎么样好用的作用、框架或语法,届时 Oracle 官方的
prodvider 不帮衬,就请各位用户自动承担,或间接以后就改用 SQL Server
来开发新的项目。

    public string connectionString = @"Data Source=(DESCRIPTION = (ADDRESS_LIST= (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = oracle11g)));user id=geovin;password=geovindu;Persist Security Info=True;";
    public string connectionString = @"Data Source=(DESCRIPTION = (ADDRESS_LIST= (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = oracle11g)));user id=geovin;password=geovindu;Persist Security Info=True;";

于是,随着 .NET 平台和 Visual Studio
更好用、经营销售越做越夸张,今后也会有愈多的开发人员、IT
决策者会「强烈提出」他们的客户,最棒使用微软的 SQL Server
(大家都省时方便),而不用用
Oracle,不然壹些开支方便性、执行质量上的甜头,例如有个别 ADO.NET /
DataReader 的语法甜头 [2],或像
LINQ to SQL 的轻量级和方便性,或是像今日 SQL Server 2010新出席的部分连串和功效:HierarchyID 阶层类型、FileStream
大型对象的储存、地理空间类型 (Spatial Data Type),或是像 Service Broker
调换新闻 (完结 SOA),或是以往某些新的 .NET 框架,若你坚定不移要用 Oracle
数据库,以上的各个大概将不能有效地和 .NET 程序整合。

  

  

若客户仍坚称相信 Oracle
才能处理海量关键的施用,没提到,微软今后会告知您,「壹般的」应用开发,用
Oracle Data Provider for .NET (ODP.NET) 或部分 OEnclaveM
框架,仍可平常运转,但必然 .NET Framework
平台的好多新功能和利益,你将会不可能享受。若你仍不爱用 SQL Server,仍想用
Oracle/Java 或 Sybase (SAP)
等其余的消除方案,请不要忘记,以后集团的运用开发,已进一步走向被 .NET /
Visual Studio 一家独揽的趋向。你的门类决不作者家的 SQL
Server,今后几年后若您的系统要改版或丰硕效果,后果自负。当然,SQL Server
只能运作在 Windows 操作系统上,最棒以往享有商店新开发的档次,都被绑在
.NET/Visual Studio + SQL Server + Windows 上,若今后几年 Java
不能够有效地发展或相继流派仍无冕分歧,连带也会潜移默化客户在新品类选拔 Oracle
数据库的意思。如此1来,二十年后微软将合并全球集团的连串后台,届时号令天下什么人敢不从。

/// <summary>
    /// 20160918 涂聚文
    /// Geovin Du
    /// </summary>
    public class BookKindListDAL : IBookKindList
    {

        ///<summary>
        /// 追加记录
        ///</summary>
        ///<param name="BookKindListInfo"></param>
        ///<returns></returns>
        public int InsertBookKindList(BookKindListInfo bookKindList)
        {
            int ret = 0;
            try
            {
                OracleParameter[] par = new OracleParameter[]{
    new OracleParameter("temTypeName",OracleType.NVarChar,1000),
    new OracleParameter("temParent",OracleType.Number,4),
    };
                par[0].Value = bookKindList.BookKindName;
                par[1].Value = bookKindList.BookKindParent;
                ret = OracleHelper.ExecuteSql("proc_Insert_BookKindList", CommandType.StoredProcedure, par);
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return ret;
        }
        /// <summary>
        /// 追加记录返回
        /// </summary>
        /// <param name="authorList"></param>
        /// <param name="authorID"></param>
        /// <returns></returns>
        public int InsertBookKindOutput(BookKindListInfo bookKindList, out int bookKindLID)
        {
            bookKindLID = 0;
            int ret = 0;
            try
            {
                OracleParameter[] par = new OracleParameter[]{
    new OracleParameter("temTypeName",OracleType.NVarChar,1000),
                new OracleParameter("temParent",OracleType.Number,4),
                new OracleParameter("temId",OracleType.Number,4),
    };
                par[0].Value = bookKindList.BookKindName;
                par[1].Value = bookKindList.BookKindParent;
                par[2].Direction = ParameterDirection.Output;
                ret = OracleHelper.ExecuteSql("proc_Insert_BookKindOut", CommandType.StoredProcedure, par);
                if (ret > 0)
                {
                    bookKindLID =int.Parse(par[2].Value.ToString());
                }
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return ret;
        }
        ///<summary>
        ///修改记录
        ///</summary>
        ///<param name="BookKindListInfo"></param>
        ///<returns></returns>
        public int UpdateBookKindList(BookKindListInfo bookKindList)
        {
            int ret = 0;
            try
            {
                OracleParameter[] par = new OracleParameter[]{
    new OracleParameter("BookKindID",OracleType.Number,4),
    new OracleParameter("BookKindName",OracleType.NVarChar,1000),
    new OracleParameter("BookKindParent",OracleType.Number,4),
    };
                par[0].Value = bookKindList.BookKindID;
                par[1].Value = bookKindList.BookKindName;
                par[2].Value = bookKindList.BookKindParent;
                ret = OracleHelper.ExecuteSql("proc_Update_BookKindList", CommandType.StoredProcedure, par);
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return ret;
        }
        ///<summary>
        /// 删除记录
        ///</summary>
        ///<param name="bookKindIDInfo"></param>
        ///<returns></returns>
        public bool DeleteBookKindList(int bookKindID)
        {
            bool ret = false;
            try
            {
                OracleParameter par = new OracleParameter("BookKindID", bookKindID);
                int temp = 0;
                temp = OracleHelper.ExecuteSql("proc_Delete_BookKindList", CommandType.StoredProcedure, par);
                if (temp != 0)
                {
                    ret = true;
                }
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return ret;
        }
        ///<summary>
        /// 查询记录
        ///</summary>
        ///<param name="bookKindIDInfo"></param>
        ///<returns></returns>
        public BookKindListInfo SelectBookKindList(int bookKindID)
        {
            BookKindListInfo bookKindList = null;
            try
            {
                OracleParameter par = new OracleParameter("BookKindID", bookKindID);
                using (OracleDataReader reader = OracleHelper.GetReader("proc_Select_BookKindList", CommandType.StoredProcedure, par))
                {
                    if (reader.Read())
                    {
                        bookKindList = new BookKindListInfo();
                        bookKindList.BookKindID = (!object.Equals(reader["BookKindID"], null)) ? (int)reader["BookKindID"] : 0;
                        bookKindList.BookKindName = (!object.Equals(reader["BookKindName"], null)) ? (string)reader["BookKindName"] : "";
                        bookKindList.BookKindParent = (!object.Equals(reader["BookKindParent"], null)) ? (int)reader["BookKindParent"] : 0;

                    }
                }
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return bookKindList;
        }

        ///<summary>
        /// 查询所有记录
        ///</summary>
        ///<returns></returns>
        public List<BookKindListInfo> SelectBookKindListAll()
        {
            List<BookKindListInfo> list = new List<BookKindListInfo>();
            BookKindListInfo bookKindList = null;
            try
            {
                using (OracleDataReader reader = OracleHelper.GetReader("proc_Select_BookKindListAll", CommandType.StoredProcedure, null))
                {
                    while (reader.Read())
                    {
                        bookKindList = new BookKindListInfo();
                        bookKindList.BookKindID = (!object.Equals(reader["BookKindID"], null)) ? (int)reader["BookKindID"] : 0;
                        bookKindList.BookKindName = (!object.Equals(reader["BookKindName"], null)) ? (string)reader["BookKindName"] : "";
                        bookKindList.BookKindParent = (!object.Equals(reader["BookKindParent"], null)) ? (int)reader["BookKindParent"] : 0;
                        list.Add(bookKindList);

                    }
                }
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return list;
        }
        ///<summary>
        /// 查询所有记录
        ///</summary>
        ///<returns></returns>
        public DataTable SelectBookKindListDataTableAll()
        {
            DataTable dt = new DataTable();
            try
            {
                using (DataTable reader = OracleHelper.GetTable("proc_Select_BookKindListAll", CommandType.StoredProcedure, null))
                {
                    dt = reader;


                }
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return dt;
        }

    }
/// <summary>
    /// 20160918 涂聚文
    /// Geovin Du
    /// </summary>
    public class BookKindListDAL : IBookKindList
    {

        ///<summary>
        /// 追加记录
        ///</summary>
        ///<param name="BookKindListInfo"></param>
        ///<returns></returns>
        public int InsertBookKindList(BookKindListInfo bookKindList)
        {
            int ret = 0;
            try
            {
                OracleParameter[] par = new OracleParameter[]{
                new OracleParameter("temTypeName",OracleType.NVarChar,1000),
                new OracleParameter("temParent",OracleType.Number,4),
                };
                par[0].Value = bookKindList.BookKindName;
                par[1].Value = bookKindList.BookKindParent;
                ret = OracleHelper.ExecuteSql("proc_Insert_BookKindList", CommandType.StoredProcedure, par);
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return ret;
        }
        /// <summary>
        /// 追加记录返回
        /// </summary>
        /// <param name="authorList"></param>
        /// <param name="authorID"></param>
        /// <returns></returns>
        public int InsertBookKindOutput(BookKindListInfo bookKindList, out int bookKindLID)
        {
            bookKindLID = 0;
            int ret = 0;
            try
            {
                OracleParameter[] par = new OracleParameter[]{
                new OracleParameter("temTypeName",OracleType.NVarChar,1000),
                new OracleParameter("temParent",OracleType.Number,4),
                new OracleParameter("temId",OracleType.Number,4),
                };
                par[0].Value = bookKindList.BookKindName;
                par[1].Value = bookKindList.BookKindParent;
                par[2].Direction = ParameterDirection.Output;
                ret = OracleHelper.ExecuteSql("proc_Insert_BookKindOut", CommandType.StoredProcedure, par);
                if (ret > 0)
                {
                    bookKindLID =int.Parse(par[2].Value.ToString());
                }
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return ret;
        }
        ///<summary>
        ///修改记录
        ///</summary>
        ///<param name="BookKindListInfo"></param>
        ///<returns></returns>
        public int UpdateBookKindList(BookKindListInfo bookKindList)
        {
            int ret = 0;
            try
            {
                OracleParameter[] par = new OracleParameter[]{
                new OracleParameter("BookKindID",OracleType.Number,4),
                new OracleParameter("BookKindName",OracleType.NVarChar,1000),
                new OracleParameter("BookKindParent",OracleType.Number,4),
                };
                par[0].Value = bookKindList.BookKindID;
                par[1].Value = bookKindList.BookKindName;
                par[2].Value = bookKindList.BookKindParent;
                ret = OracleHelper.ExecuteSql("proc_Update_BookKindList", CommandType.StoredProcedure, par);
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return ret;
        }
        ///<summary>
        /// 删除记录
        ///</summary>
        ///<param name="bookKindIDInfo"></param>
        ///<returns></returns>
        public bool DeleteBookKindList(int bookKindID)
        {
            bool ret = false;
            try
            {
                OracleParameter par = new OracleParameter("BookKindID", bookKindID);
                int temp = 0;
                temp = OracleHelper.ExecuteSql("proc_Delete_BookKindList", CommandType.StoredProcedure, par);
                if (temp != 0)
                {
                    ret = true;
                }
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return ret;
        }
        ///<summary>
        /// 查询记录
        ///</summary>
        ///<param name="bookKindIDInfo"></param>
        ///<returns></returns>
        public BookKindListInfo SelectBookKindList(int bookKindID)
        {
            BookKindListInfo bookKindList = null;
            try
            {
                OracleParameter par = new OracleParameter("BookKindID", bookKindID);
                using (OracleDataReader reader = OracleHelper.GetReader("proc_Select_BookKindList", CommandType.StoredProcedure, par))
                {
                    if (reader.Read())
                    {
                        bookKindList = new BookKindListInfo();
                        bookKindList.BookKindID = (!object.Equals(reader["BookKindID"], null)) ? (int)reader["BookKindID"] : 0;
                        bookKindList.BookKindName = (!object.Equals(reader["BookKindName"], null)) ? (string)reader["BookKindName"] : "";
                        bookKindList.BookKindParent = (!object.Equals(reader["BookKindParent"], null)) ? (int)reader["BookKindParent"] : 0;

                    }
                }
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return bookKindList;
        }

        ///<summary>
        /// 查询所有记录
        ///</summary>
        ///<returns></returns>
        public List<BookKindListInfo> SelectBookKindListAll()
        {
            List<BookKindListInfo> list = new List<BookKindListInfo>();
            BookKindListInfo bookKindList = null;
            try
            {
                using (OracleDataReader reader = OracleHelper.GetReader("proc_Select_BookKindListAll", CommandType.StoredProcedure, null))
                {
                    while (reader.Read())
                    {
                        bookKindList = new BookKindListInfo();
                        bookKindList.BookKindID = (!object.Equals(reader["BookKindID"], null)) ? (int)reader["BookKindID"] : 0;
                        bookKindList.BookKindName = (!object.Equals(reader["BookKindName"], null)) ? (string)reader["BookKindName"] : "";
                        bookKindList.BookKindParent = (!object.Equals(reader["BookKindParent"], null)) ? (int)reader["BookKindParent"] : 0;
                        list.Add(bookKindList);

                    }
                }
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return list;
        }
        ///<summary>
        /// 查询所有记录
        ///</summary>
        ///<returns></returns>
        public DataTable SelectBookKindListDataTableAll()
        {
            DataTable dt = new DataTable();
            try
            {
                using (DataTable reader = OracleHelper.GetTable("proc_Select_BookKindListAll", CommandType.StoredProcedure, null))
                {
                    dt = reader;


                }
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return dt;
        }

    }

正文同步揭橥在「ADO.NET – 今日头条小组」:

  System.Data.OleDb

  System.Data.OleDb


 string connString = "Provider=OraOLEDB.Oracle.1;User ID=geovin;Password=geovindu;Data Source=(DESCRIPTION = (ADDRESS_LIST= (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = oracle11g)))";
            OleDbConnection conn = new OleDbConnection(connString);
            try
            {
                conn.Open();
                MessageBox.Show(conn.State.ToString());
                DataTable dt = conn.GetSchema(this.comboBox1.Text.Trim());
                this.dataGridView1.DataSource = dt;
                this.textBox1.Text = GetColumnNames(dt);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
            finally
            {
                conn.Close();
            }
 string connString = "Provider=OraOLEDB.Oracle.1;User ID=geovin;Password=geovindu;Data Source=(DESCRIPTION = (ADDRESS_LIST= (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = oracle11g)))";
            OleDbConnection conn = new OleDbConnection(connString);
            try
            {
                conn.Open();
                MessageBox.Show(conn.State.ToString());
                DataTable dt = conn.GetSchema(this.comboBox1.Text.Trim());
                this.dataGridView1.DataSource = dt;
                this.textBox1.Text = GetColumnNames(dt);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
            finally
            {
                conn.Close();
            }

连带小说:

  oracle package sql:

  oracle package sql:

[1] Oracle and ADO.NET (.NET 四, 普通话版的内容从未更新)

/**创建一个名为pkgBookKinds的包查所表中所有内容**/
create or replace package pkg_BookKinds is
--定义一个公有的游标类型cursor_pdt
--ref 可以在程序间传递结果集
--一个程序里打开游标变量,在另外的程序里处理数据
type cursor_pdt is ref cursor;
--声明一个存储过程 ,游标类型参数为输出类型
procedure proc_GetAllBookKind(cur_set out cursor_pdt);
end pkg_BookKinds;

/**创建一个包体**/
create or replace package body pkg_BookKinds is
  --实现包中没有实现的存储过程
  procedure proc_GetAllBookKind(cur_set out cursor_pdt) as
    begin 
      --打开游标,由于定义游标时使用ref处理游标可以推迟到客户端
      open cur_set for select * from BookKindList;
      end;
end;


/**使用过程测试定义的存储过程**/
declare
--定义游标类型的变量
cur_set pkg_BookKinds.cursor_pdt;
--定义行类型
pdtrow BookKindList%rowtype;
begin
  --执行存储过程
  pkg_BookKinds.proc_GetAllBookKind(cur_set);
  --遍历游标中的数据
       LOOP
         --取当前行数据存入pdtrow
           FETCH cur_set INTO pdtrow;
           --如果未获取数据就结束循环
           EXIT WHEN cur_set%NOTFOUND;
           --输出获取到的数据
           DBMS_OUTPUT.PUT_LINE (pdtrow.BookKindID||','||pdtrow.BookKindName);
         END LOOP;
         CLOSE cur_set;
  end;
/**创建一个名为pkgBookKinds的包查所表中所有内容**/
create or replace package pkg_BookKinds is
--定义一个公有的游标类型cursor_pdt
--ref 可以在程序间传递结果集
--一个程序里打开游标变量,在另外的程序里处理数据
type cursor_pdt is ref cursor;
--声明一个存储过程 ,游标类型参数为输出类型
procedure proc_GetAllBookKind(cur_set out cursor_pdt);
end pkg_BookKinds;

/**创建一个包体**/
create or replace package body pkg_BookKinds is
  --实现包中没有实现的存储过程
  procedure proc_GetAllBookKind(cur_set out cursor_pdt) as
    begin 
      --打开游标,由于定义游标时使用ref处理游标可以推迟到客户端
      open cur_set for select * from BookKindList;
      end;
end;


/**使用过程测试定义的存储过程**/
declare
--定义游标类型的变量
cur_set pkg_BookKinds.cursor_pdt;
--定义行类型
pdtrow BookKindList%rowtype;
begin
  --执行存储过程
  pkg_BookKinds.proc_GetAllBookKind(cur_set);
  --遍历游标中的数据
       LOOP
         --取当前行数据存入pdtrow
           FETCH cur_set INTO pdtrow;
           --如果未获取数据就结束循环
           EXIT WHEN cur_set%NOTFOUND;
           --输出获取到的数据
           DBMS_OUTPUT.PUT_LINE (pdtrow.BookKindID||','||pdtrow.BookKindName);
         END LOOP;
         CLOSE cur_set;
  end;

[2] DataReader 程序质量优化、透过 SqlConnection 的 ChangeDatabase
方法切换差别数据库而不启用分布式事务

 

 

[3]4858.com, System.Data.OracleClient 将走入历史, 小编:李明儒 (繁体中文)

--创建包以游标的形式返回BookKindList的结果集
create or replace package pkg_BookKindList is
-- Author  : geovindu
  type mycur is ref cursor;  
  procedure fun_GetRecords(cur_return out mycur);
end pkg_BookKindList;

create or replace package body pkg_BookKindList is
  -- Function and procedure implementations
 procedure fun_GetRecords(cur_return out mycur)
  is    
  begin
   open cur_return for select * from BookKindList;

  end fun_GetRecords;

end pkg_BookKindList;


declare 
--定义游标类型的变量
cur_return pkg_BookKindList.mycur;
--定义行类型
pdtrow BookKindList%rowtype;
begin
  --执行存储过程
  pkg_BookKindList.fun_GetRecords(cur_return);
  --遍历游标中的数据
       LOOP
         --取当前行数据存入pdtrow
           FETCH cur_return INTO pdtrow;
           --如果未获取数据就结束循环
           EXIT WHEN cur_return%NOTFOUND;
           --输出获取到的数据
           DBMS_OUTPUT.PUT_LINE (pdtrow.BookKindID||','||pdtrow.BookKindName);
         END LOOP;
         CLOSE cur_return;
end;
--创建包以游标的形式返回BookKindList的结果集
create or replace package pkg_BookKindList is
-- Author  : geovindu
  type mycur is ref cursor;  
  procedure fun_GetRecords(cur_return out mycur);
end pkg_BookKindList;

create or replace package body pkg_BookKindList is
  -- Function and procedure implementations
 procedure fun_GetRecords(cur_return out mycur)
  is    
  begin
   open cur_return for select * from BookKindList;

  end fun_GetRecords;

end pkg_BookKindList;


declare 
--定义游标类型的变量
cur_return pkg_BookKindList.mycur;
--定义行类型
pdtrow BookKindList%rowtype;
begin
  --执行存储过程
  pkg_BookKindList.fun_GetRecords(cur_return);
  --遍历游标中的数据
       LOOP
         --取当前行数据存入pdtrow
           FETCH cur_return INTO pdtrow;
           --如果未获取数据就结束循环
           EXIT WHEN cur_return%NOTFOUND;
           --输出获取到的数据
           DBMS_OUTPUT.PUT_LINE (pdtrow.BookKindID||','||pdtrow.BookKindName);
         END LOOP;
         CLOSE cur_return;
end;

[4] migrate to the Oracle Data Provider for .NET

  

  

[5] 其余互联网小说 (简体中文)

 

 

[6] Oracle 1壹g 学习笔记

 C# 叁.5 调用查询:

 C# 三.5 调用查询:


 /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form3_Load(object sender, EventArgs e)
        {
            BindGridView();
        }
        /// <summary>
        /// 
        /// </summary>
        private void BindGridView()
        {
            OracleConnection conn = new OracleConnection(connectionString);
            //ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString
            OracleCommand comm = new OracleCommand("pkg_BookKindList.fun_GetRecords", conn);
            comm.Parameters.Add("cur_return", OracleType.Cursor).Direction = ParameterDirection.Output;
            comm.CommandType = CommandType.StoredProcedure;
            DataSet ds = new DataSet();
            using (OracleDataAdapter da = new OracleDataAdapter(comm))
            {

                da.Fill(ds);
            }
            this.dataGridView1.DataSource = ds.Tables[0].DefaultView;


        }
 /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form3_Load(object sender, EventArgs e)
        {
            BindGridView();
        }
        /// <summary>
        /// 
        /// </summary>
        private void BindGridView()
        {
            OracleConnection conn = new OracleConnection(connectionString);
            //ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString
            OracleCommand comm = new OracleCommand("pkg_BookKindList.fun_GetRecords", conn);
            comm.Parameters.Add("cur_return", OracleType.Cursor).Direction = ParameterDirection.Output;
            comm.CommandType = CommandType.StoredProcedure;
            DataSet ds = new DataSet();
            using (OracleDataAdapter da = new OracleDataAdapter(comm))
            {

                da.Fill(ds);
            }
            this.dataGridView1.DataSource = ds.Tables[0].DefaultView;


        }

  

  

 /// <summary>
        /// 
        /// </summary>
        private void BindGridViewOther()
        {
            OracleConnection conn = new OracleConnection(connectionString);
            //ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString
            OracleCommand comm = new OracleCommand("pkg_BookKindList.fun_GetRecords", conn);
            comm.CommandType = CommandType.StoredProcedure;
            //定义参数,注意参数名必须与存储过程定义时一致,且类型为OracleType.Cursor
            OracleParameter cur_set = new OracleParameter("cur_return", OracleType.Cursor);
            //设置参数为输出类型
            cur_set.Direction = ParameterDirection.Output;           
            //添加参数
            comm.Parameters.Add(cur_set);
            DataSet ds = new DataSet();
            using (OracleDataAdapter da = new OracleDataAdapter(comm))
            {

                da.Fill(ds);
            }
            this.dataGridView1.DataSource = ds.Tables[0].DefaultView;


        }
 /// <summary>
        /// 
        /// </summary>
        private void BindGridViewOther()
        {
            OracleConnection conn = new OracleConnection(connectionString);
            //ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString
            OracleCommand comm = new OracleCommand("pkg_BookKindList.fun_GetRecords", conn);
            comm.CommandType = CommandType.StoredProcedure;
            //定义参数,注意参数名必须与存储过程定义时一致,且类型为OracleType.Cursor
            OracleParameter cur_set = new OracleParameter("cur_return", OracleType.Cursor);
            //设置参数为输出类型
            cur_set.Direction = ParameterDirection.Output;           
            //添加参数
            comm.Parameters.Add(cur_set);
            DataSet ds = new DataSet();
            using (OracleDataAdapter da = new OracleDataAdapter(comm))
            {

                da.Fill(ds);
            }
            this.dataGridView1.DataSource = ds.Tables[0].DefaultView;


        }

  

  

Oracle sql:

Oracle sql:

---某条记录的字段
drop PROCEDURE proc_Select_BookKindName;

CREATE OR REPLACE PROCEDURE proc_Select_BookKindName(kind_id IN BookKindList.BookKindID%type) AS
    --声明语句段
    v_name varchar2(20);
BEGIN
    --执行语句段
    SELECT o.BookKindName INTO v_name FROM BookKindList o where o.BookKindID=kind_id;
    dbms_output.put_line(v_name);
EXCEPTION
    --异常处理语句段
    WHEN NO_DATA_FOUND THEN dbms_output.put_line('NO_DATA_FOUND');
END;

--测试
begin
proc_Select_BookKindName(1);
end;



---一条记录
--创建包:
create or replace package pack_BookKindId is 
       type cur_BookKindId is ref cursor;  
end pack_BookKindId; 
--创建存储过程
create or replace procedure proc_curBookKindId(p_id in number,p_cur out pack_BookKindId.cur_BookKindId) 
is   
       v_sql varchar2(400);
begin  

       if p_id = 0 then   
          open p_cur for select * from BookKindList; 
       else   
          v_sql := 'select * from BookKindList where BookKindID =: p_id';  
          open p_cur for v_sql using p_id;   
       end if;  
end proc_curBookKindId;


--测试查询一条记录存储过程
-- Test statements here  
set serveroutput on
declare   
 v_id number := 1; --0 时,所有记录 
 v_row BookKindList%rowtype;   --注意这里是表名
 p_cur pack_BookKindId.cur_BookKindId;
begin   
 proc_curBookKindId(v_id, p_cur);  
 loop  
    fetch p_cur into v_row;  
    exit when p_cur%notfound;  
    DBMS_OUTPUT.PUT_LINE(v_row.BookKindName||'='||v_row.BookKindID);  
 end loop;  
 close p_cur;  
end; 
---某条记录的字段
drop PROCEDURE proc_Select_BookKindName;

CREATE OR REPLACE PROCEDURE proc_Select_BookKindName(kind_id IN BookKindList.BookKindID%type) AS
    --声明语句段
    v_name varchar2(20);
BEGIN
    --执行语句段
    SELECT o.BookKindName INTO v_name FROM BookKindList o where o.BookKindID=kind_id;
    dbms_output.put_line(v_name);
EXCEPTION
    --异常处理语句段
    WHEN NO_DATA_FOUND THEN dbms_output.put_line('NO_DATA_FOUND');
END;

--测试
begin
proc_Select_BookKindName(1);
end;



---一条记录
--创建包:
create or replace package pack_BookKindId is 
       type cur_BookKindId is ref cursor;  
end pack_BookKindId; 
--创建存储过程
create or replace procedure proc_curBookKindId(p_id in number,p_cur out pack_BookKindId.cur_BookKindId) 
is   
       v_sql varchar2(400);
begin  

       if p_id = 0 then   
          open p_cur for select * from BookKindList; 
       else   
          v_sql := 'select * from BookKindList where BookKindID =: p_id';  
          open p_cur for v_sql using p_id;   
       end if;  
end proc_curBookKindId;


--测试查询一条记录存储过程
-- Test statements here  
set serveroutput on
declare   
 v_id number := 1; --0 时,所有记录 
 v_row BookKindList%rowtype;   --注意这里是表名
 p_cur pack_BookKindId.cur_BookKindId;
begin   
 proc_curBookKindId(v_id, p_cur);  
 loop  
    fetch p_cur into v_row;  
    exit when p_cur%notfound;  
    DBMS_OUTPUT.PUT_LINE(v_row.BookKindName||'='||v_row.BookKindID);  
 end loop;  
 close p_cur;  
end; 

  

  

ODP.NET:

ODP.NET:

  ///<summary>
        /// 查询所有记录
        ///</summary>
        ///<returns></returns>
        public List<BookKindListInfo> SelectBookKindListAll()
        {
            List<BookKindListInfo> list = new List<BookKindListInfo>();
            BookKindListInfo bookKindList = null;
            try
            {
                //定义参数,注意参数名必须与存储过程定义时一致,且类型为OracleType.Cursor
                OracleParameter cur_set = new OracleParameter("cur_return", OracleDbType.RefCursor);
                //设置参数为输出类型
                cur_set.Direction = ParameterDirection.Output;
                //OracleHelper.ExecuteReader(connectionString, CommandType.StoredProcedure, "pkg_Select_BookKindListAll.proc_Select_BookKindListAll", cur_set)
                using (OracleDataReader reader = OracleHelper.GetReader("pkg_Select_BookKindListAll.proc_Select_BookKindListAll", CommandType.StoredProcedure, cur_set))
                {
                    while (reader.Read())
                    {
                        bookKindList = new BookKindListInfo();
                        string s = reader["BookKindID"].ToString();
                        bookKindList.BookKindID = (!object.Equals(reader["BookKindID"], null)) ? (decimal)reader["BookKindID"] : 0;
                        bookKindList.BookKindName = (!object.Equals(reader["BookKindName"], null)) ? (string)reader["BookKindName"] : "";
                        bookKindList.BookKindParent = (!object.Equals(reader["BookKindParent"], null)) ? (decimal)reader["BookKindParent"] : 0;
                        list.Add(bookKindList);

                    }
                }
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return list;
        }
        ///<summary>
        /// 查询所有记录
        ///</summary>
        ///<returns></returns>
        public DataTable SelectBookKindListDataTableAll()
        {
            DataTable dt = new DataTable();
            try
            {
                //定义参数,注意参数名必须与存储过程定义时一致,且类型为OracleType.Cursor
                OracleParameter cur_set = new OracleParameter("cur_return", OracleDbType.RefCursor);
                //设置参数为输出类型
                cur_set.Direction = ParameterDirection.Output;
                //添加参数
                //comm.Parameters.Add(cur_set);
                using (DataTable reader = OracleHelper.GetTable("pkg_Select_BookKindListAll.proc_Select_BookKindListAll", CommandType.StoredProcedure, cur_set))
                {
                    dt = reader;


                }
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return dt;
        }
  ///<summary>
        /// 查询所有记录
        ///</summary>
        ///<returns></returns>
        public List<BookKindListInfo> SelectBookKindListAll()
        {
            List<BookKindListInfo> list = new List<BookKindListInfo>();
            BookKindListInfo bookKindList = null;
            try
            {
                //定义参数,注意参数名必须与存储过程定义时一致,且类型为OracleType.Cursor
                OracleParameter cur_set = new OracleParameter("cur_return", OracleDbType.RefCursor);
                //设置参数为输出类型
                cur_set.Direction = ParameterDirection.Output;
                //OracleHelper.ExecuteReader(connectionString, CommandType.StoredProcedure, "pkg_Select_BookKindListAll.proc_Select_BookKindListAll", cur_set)
                using (OracleDataReader reader = OracleHelper.GetReader("pkg_Select_BookKindListAll.proc_Select_BookKindListAll", CommandType.StoredProcedure, cur_set))
                {
                    while (reader.Read())
                    {
                        bookKindList = new BookKindListInfo();
                        string s = reader["BookKindID"].ToString();
                        bookKindList.BookKindID = (!object.Equals(reader["BookKindID"], null)) ? (decimal)reader["BookKindID"] : 0;
                        bookKindList.BookKindName = (!object.Equals(reader["BookKindName"], null)) ? (string)reader["BookKindName"] : "";
                        bookKindList.BookKindParent = (!object.Equals(reader["BookKindParent"], null)) ? (decimal)reader["BookKindParent"] : 0;
                        list.Add(bookKindList);

                    }
                }
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return list;
        }
        ///<summary>
        /// 查询所有记录
        ///</summary>
        ///<returns></returns>
        public DataTable SelectBookKindListDataTableAll()
        {
            DataTable dt = new DataTable();
            try
            {
                //定义参数,注意参数名必须与存储过程定义时一致,且类型为OracleType.Cursor
                OracleParameter cur_set = new OracleParameter("cur_return", OracleDbType.RefCursor);
                //设置参数为输出类型
                cur_set.Direction = ParameterDirection.Output;
                //添加参数
                //comm.Parameters.Add(cur_set);
                using (DataTable reader = OracleHelper.GetTable("pkg_Select_BookKindListAll.proc_Select_BookKindListAll", CommandType.StoredProcedure, cur_set))
                {
                    dt = reader;


                }
            }
            catch (OracleException ex)
            {
                throw ex;
            }
            return dt;
        }

  

  

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图
Copyright @ 2010-2019 美高梅手机版4858 版权所有