首页 > 代码库 > C#通过OleDb查询Oracle存储过程

C#通过OleDb查询Oracle存储过程

using System;
using System.Data;
using System.Data.OleDb;

  

        /// <summary>
        /// 通过OleDb查询Oracle存储过程
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static DataTable getTodoList(string id)
        {
            string connString1 = "provider=OraOLEDB.Oracle.1;User ID=test;Password=test;Data Source=(DESCRIPTION = (ADDRESS_LIST= (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))) (CONNECT_DATA = http://www.mamicode.com/(SERVICE_NAME = orcl)));Persist Security Info=True;Extended Properties=‘PLSQLRSet=1‘;";//‘PLSQLRSet=1‘很重要

            DataSet ds = new DataSet();
            DataTable dt = new DataTable();
            OleDbConnection conn = new OleDbConnection(connString1);
            OleDbCommand cmd = new OleDbCommand("getTodoList", conn);
            cmd.CommandType = CommandType.StoredProcedure;

            try
            {
                conn.Open();

                OleDbParameter[] parms = {
                                         new OleDbParameter("id1", OleDbType  .VarChar)
                                     };
                parms[0].Value = http://www.mamicode.com/id;>

  

C#通过OleDb查询Oracle存储过程