ODP.NET:

引用:

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

  数据库连接字符串:

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

  

  1. /// <summary>
  2. /// 20160918 涂聚文
  3. /// Geovin Du
  4. /// </summary>
  5. public class BookKindListDAL : IBookKindList
  6. {
  7.  
  8. ///<summary>
  9. /// 追加记录
  10. ///</summary>
  11. ///<param name="BookKindListInfo"></param>
  12. ///<returns></returns>
  13. public int InsertBookKindList(BookKindListInfo bookKindList)
  14. {
  15. int ret = 0;
  16. try
  17. {
  18. OracleParameter[] par = new OracleParameter[]{
  19. new OracleParameter("temTypeName",OracleDbType.NVarchar2,1000),
  20. new OracleParameter("temParent",OracleDbType.Int32,4),
  21. };
  22. par[0].Value = bookKindList.BookKindName;
  23. par[1].Value = bookKindList.BookKindParent;
  24. ret = OracleHelper.ExecuteSql("proc_Insert_BookKindList", CommandType.StoredProcedure, par);
  25. }
  26. catch (OracleException ex)
  27. {
  28. throw ex;
  29. }
  30. return ret;
  31. }
  32. /// <summary>
  33. /// 追加记录返回
  34. /// </summary>
  35. /// <param name="authorList"></param>
  36. /// <param name="authorID"></param>
  37. /// <returns></returns>
  38. public int InsertBookKindOutput(BookKindListInfo bookKindList, out int bookKindLID)
  39. {
  40. bookKindLID = 0;
  41. int ret = 0;
  42. try
  43. {
  44. OracleParameter[] par = new OracleParameter[]{
  45. new OracleParameter("temTypeName",OracleDbType.NVarchar2,1000),
  46. new OracleParameter("temParent",OracleDbType.Int32,4),
  47. new OracleParameter("temId",OracleDbType.Int32,4),
  48. };
  49. par[0].Value = bookKindList.BookKindName;
  50. par[1].Value = bookKindList.BookKindParent;
  51. par[2].Direction = ParameterDirection.Output;
  52. ret = OracleHelper.ExecuteSql("proc_Insert_BookKindOut", CommandType.StoredProcedure, par);
  53. if (ret > 0)
  54. {
  55. bookKindLID =int.Parse(par[2].Value.ToString());
  56. }
  57. }
  58. catch (OracleException ex)
  59. {
  60. throw ex;
  61. }
  62. return ret;
  63. }
  64. ///<summary>
  65. ///修改记录
  66. ///</summary>
  67. ///<param name="BookKindListInfo"></param>
  68. ///<returns></returns>
  69. public int UpdateBookKindList(BookKindListInfo bookKindList)
  70. {
  71. int ret = 0;
  72. try
  73. {
  74. OracleParameter[] par = new OracleParameter[]{
  75. new OracleParameter("BookKindID",OracleDbType.Int32,4),
  76. new OracleParameter("BookKindName",OracleDbType.NVarchar2,1000),
  77. new OracleParameter("BookKindParent",OracleDbType.Int32,4),
  78. };
  79. par[0].Value = bookKindList.BookKindID;
  80. par[1].Value = bookKindList.BookKindName;
  81. par[2].Value = bookKindList.BookKindParent;
  82. ret = OracleHelper.ExecuteSql("proc_Update_BookKindList", CommandType.StoredProcedure, par);
  83. }
  84. catch (OracleException ex)
  85. {
  86. throw ex;
  87. }
  88. return ret;
  89. }
  90. ///<summary>
  91. /// 删除记录
  92. ///</summary>
  93. ///<param name="bookKindIDInfo"></param>
  94. ///<returns></returns>
  95. public bool DeleteBookKindList(int bookKindID)
  96. {
  97. bool ret = false;
  98. try
  99. {
  100. OracleParameter par = new OracleParameter("BookKindID", bookKindID);
  101. int temp = 0;
  102. temp = OracleHelper.ExecuteSql("proc_Delete_BookKindList", CommandType.StoredProcedure, par);
  103. if (temp != 0)
  104. {
  105. ret = true;
  106. }
  107. }
  108. catch (OracleException ex)
  109. {
  110. throw ex;
  111. }
  112. return ret;
  113. }
  114. ///<summary>
  115. /// 查询记录
  116. ///</summary>
  117. ///<param name="bookKindIDInfo"></param>
  118. ///<returns></returns>
  119. public BookKindListInfo SelectBookKindList(int bookKindID)
  120. {
  121. BookKindListInfo bookKindList = null;
  122. try
  123. {
  124. OracleParameter par = new OracleParameter("BookKindID", bookKindID);
  125. using (OracleDataReader reader = OracleHelper.GetReader("proc_Select_BookKindList", CommandType.StoredProcedure, par))
  126. {
  127. if (reader.Read())
  128. {
  129. bookKindList = new BookKindListInfo();
  130. bookKindList.BookKindID = (!object.Equals(reader["BookKindID"], null)) ? (int)reader["BookKindID"] : 0;
  131. bookKindList.BookKindName = (!object.Equals(reader["BookKindName"], null)) ? (string)reader["BookKindName"] : "";
  132. bookKindList.BookKindParent = (!object.Equals(reader["BookKindParent"], null)) ? (int)reader["BookKindParent"] : 0;
  133.  
  134. }
  135. }
  136. }
  137. catch (OracleException ex)
  138. {
  139. throw ex;
  140. }
  141. return bookKindList;
  142. }
  143.  
  144. ///<summary>
  145. /// 查询所有记录
  146. ///</summary>
  147. ///<returns></returns>
  148. public List<BookKindListInfo> SelectBookKindListAll()
  149. {
  150. List<BookKindListInfo> list = new List<BookKindListInfo>();
  151. BookKindListInfo bookKindList = null;
  152. try
  153. {
  154. using (OracleDataReader reader = OracleHelper.GetReader("proc_Select_BookKindListAll", CommandType.StoredProcedure, null))
  155. {
  156. while (reader.Read())
  157. {
  158. bookKindList = new BookKindListInfo();
  159. bookKindList.BookKindID = (!object.Equals(reader["BookKindID"], null)) ? (int)reader["BookKindID"] : 0;
  160. bookKindList.BookKindName = (!object.Equals(reader["BookKindName"], null)) ? (string)reader["BookKindName"] : "";
  161. bookKindList.BookKindParent = (!object.Equals(reader["BookKindParent"], null)) ? (int)reader["BookKindParent"] : 0;
  162. list.Add(bookKindList);
  163.  
  164. }
  165. }
  166. }
  167. catch (OracleException ex)
  168. {
  169. throw ex;
  170. }
  171. return list;
  172. }
  173. ///<summary>
  174. /// 查询所有记录
  175. ///</summary>
  176. ///<returns></returns>
  177. public DataTable SelectBookKindListDataTableAll()
  178. {
  179. DataTable dt = new DataTable();
  180. try
  181. {
  182. using (DataTable reader = OracleHelper.GetTable("proc_Select_BookKindListAll", CommandType.StoredProcedure, null))
  183. {
  184. dt = reader;
  185.  
  186. }
  187. }
  188. catch (OracleException ex)
  189. {
  190. throw ex;
  191. }
  192. return dt;
  193. }
  194.  
  195. }

  System.Data.OracleClient(.net 4.0)

引用:

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

  数据库连接字符串:

  1. 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;";

  

  1. /// <summary>
  2. /// 20160918 涂聚文
  3. /// Geovin Du
  4. /// </summary>
  5. public class BookKindListDAL : IBookKindList
  6. {
  7.  
  8. ///<summary>
  9. /// 追加记录
  10. ///</summary>
  11. ///<param name="BookKindListInfo"></param>
  12. ///<returns></returns>
  13. public int InsertBookKindList(BookKindListInfo bookKindList)
  14. {
  15. int ret = 0;
  16. try
  17. {
  18. OracleParameter[] par = new OracleParameter[]{
  19. new OracleParameter("temTypeName",OracleType.NVarChar,1000),
  20. new OracleParameter("temParent",OracleType.Number,4),
  21. };
  22. par[0].Value = bookKindList.BookKindName;
  23. par[1].Value = bookKindList.BookKindParent;
  24. ret = OracleHelper.ExecuteSql("proc_Insert_BookKindList", CommandType.StoredProcedure, par);
  25. }
  26. catch (OracleException ex)
  27. {
  28. throw ex;
  29. }
  30. return ret;
  31. }
  32. /// <summary>
  33. /// 追加记录返回
  34. /// </summary>
  35. /// <param name="authorList"></param>
  36. /// <param name="authorID"></param>
  37. /// <returns></returns>
  38. public int InsertBookKindOutput(BookKindListInfo bookKindList, out int bookKindLID)
  39. {
  40. bookKindLID = 0;
  41. int ret = 0;
  42. try
  43. {
  44. OracleParameter[] par = new OracleParameter[]{
  45. new OracleParameter("temTypeName",OracleType.NVarChar,1000),
  46. new OracleParameter("temParent",OracleType.Number,4),
  47. new OracleParameter("temId",OracleType.Number,4),
  48. };
  49. par[0].Value = bookKindList.BookKindName;
  50. par[1].Value = bookKindList.BookKindParent;
  51. par[2].Direction = ParameterDirection.Output;
  52. ret = OracleHelper.ExecuteSql("proc_Insert_BookKindOut", CommandType.StoredProcedure, par);
  53. if (ret > 0)
  54. {
  55. bookKindLID =int.Parse(par[2].Value.ToString());
  56. }
  57. }
  58. catch (OracleException ex)
  59. {
  60. throw ex;
  61. }
  62. return ret;
  63. }
  64. ///<summary>
  65. ///修改记录
  66. ///</summary>
  67. ///<param name="BookKindListInfo"></param>
  68. ///<returns></returns>
  69. public int UpdateBookKindList(BookKindListInfo bookKindList)
  70. {
  71. int ret = 0;
  72. try
  73. {
  74. OracleParameter[] par = new OracleParameter[]{
  75. new OracleParameter("BookKindID",OracleType.Number,4),
  76. new OracleParameter("BookKindName",OracleType.NVarChar,1000),
  77. new OracleParameter("BookKindParent",OracleType.Number,4),
  78. };
  79. par[0].Value = bookKindList.BookKindID;
  80. par[1].Value = bookKindList.BookKindName;
  81. par[2].Value = bookKindList.BookKindParent;
  82. ret = OracleHelper.ExecuteSql("proc_Update_BookKindList", CommandType.StoredProcedure, par);
  83. }
  84. catch (OracleException ex)
  85. {
  86. throw ex;
  87. }
  88. return ret;
  89. }
  90. ///<summary>
  91. /// 删除记录
  92. ///</summary>
  93. ///<param name="bookKindIDInfo"></param>
  94. ///<returns></returns>
  95. public bool DeleteBookKindList(int bookKindID)
  96. {
  97. bool ret = false;
  98. try
  99. {
  100. OracleParameter par = new OracleParameter("BookKindID", bookKindID);
  101. int temp = 0;
  102. temp = OracleHelper.ExecuteSql("proc_Delete_BookKindList", CommandType.StoredProcedure, par);
  103. if (temp != 0)
  104. {
  105. ret = true;
  106. }
  107. }
  108. catch (OracleException ex)
  109. {
  110. throw ex;
  111. }
  112. return ret;
  113. }
  114. ///<summary>
  115. /// 查询记录
  116. ///</summary>
  117. ///<param name="bookKindIDInfo"></param>
  118. ///<returns></returns>
  119. public BookKindListInfo SelectBookKindList(int bookKindID)
  120. {
  121. BookKindListInfo bookKindList = null;
  122. try
  123. {
  124. OracleParameter par = new OracleParameter("BookKindID", bookKindID);
  125. using (OracleDataReader reader = OracleHelper.GetReader("proc_Select_BookKindList", CommandType.StoredProcedure, par))
  126. {
  127. if (reader.Read())
  128. {
  129. bookKindList = new BookKindListInfo();
  130. bookKindList.BookKindID = (!object.Equals(reader["BookKindID"], null)) ? (int)reader["BookKindID"] : 0;
  131. bookKindList.BookKindName = (!object.Equals(reader["BookKindName"], null)) ? (string)reader["BookKindName"] : "";
  132. bookKindList.BookKindParent = (!object.Equals(reader["BookKindParent"], null)) ? (int)reader["BookKindParent"] : 0;
  133.  
  134. }
  135. }
  136. }
  137. catch (OracleException ex)
  138. {
  139. throw ex;
  140. }
  141. return bookKindList;
  142. }
  143.  
  144. ///<summary>
  145. /// 查询所有记录
  146. ///</summary>
  147. ///<returns></returns>
  148. public List<BookKindListInfo> SelectBookKindListAll()
  149. {
  150. List<BookKindListInfo> list = new List<BookKindListInfo>();
  151. BookKindListInfo bookKindList = null;
  152. try
  153. {
  154. using (OracleDataReader reader = OracleHelper.GetReader("proc_Select_BookKindListAll", CommandType.StoredProcedure, null))
  155. {
  156. while (reader.Read())
  157. {
  158. bookKindList = new BookKindListInfo();
  159. bookKindList.BookKindID = (!object.Equals(reader["BookKindID"], null)) ? (int)reader["BookKindID"] : 0;
  160. bookKindList.BookKindName = (!object.Equals(reader["BookKindName"], null)) ? (string)reader["BookKindName"] : "";
  161. bookKindList.BookKindParent = (!object.Equals(reader["BookKindParent"], null)) ? (int)reader["BookKindParent"] : 0;
  162. list.Add(bookKindList);
  163.  
  164. }
  165. }
  166. }
  167. catch (OracleException ex)
  168. {
  169. throw ex;
  170. }
  171. return list;
  172. }
  173. ///<summary>
  174. /// 查询所有记录
  175. ///</summary>
  176. ///<returns></returns>
  177. public DataTable SelectBookKindListDataTableAll()
  178. {
  179. DataTable dt = new DataTable();
  180. try
  181. {
  182. using (DataTable reader = OracleHelper.GetTable("proc_Select_BookKindListAll", CommandType.StoredProcedure, null))
  183. {
  184. dt = reader;
  185.  
  186. }
  187. }
  188. catch (OracleException ex)
  189. {
  190. throw ex;
  191. }
  192. return dt;
  193. }
  194.  
  195. }

  System.Data.OleDb

  1. 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)))";
  2. OleDbConnection conn = new OleDbConnection(connString);
  3. try
  4. {
  5. conn.Open();
  6. MessageBox.Show(conn.State.ToString());
  7. DataTable dt = conn.GetSchema(this.comboBox1.Text.Trim());
  8. this.dataGridView1.DataSource = dt;
  9. this.textBox1.Text = GetColumnNames(dt);
  10. }
  11. catch (Exception ex)
  12. {
  13. MessageBox.Show(ex.Message.ToString());
  14. }
  15. finally
  16. {
  17. conn.Close();
  18. }

  oracle package sql:

  1. /**创建一个名为pkgBookKinds的包查所表中所有内容**/
  2. create or replace package pkg_BookKinds is
  3. --定义一个公有的游标类型cursor_pdt
  4. --ref 可以在程序间传递结果集
  5. --一个程序里打开游标变量,在另外的程序里处理数据
  6. type cursor_pdt is ref cursor;
  7. --声明一个存储过程 ,游标类型参数为输出类型
  8. procedure proc_GetAllBookKind(cur_set out cursor_pdt);
  9. end pkg_BookKinds;
  10.  
  11. /**创建一个包体**/
  12. create or replace package body pkg_BookKinds is
  13. --实现包中没有实现的存储过程
  14. procedure proc_GetAllBookKind(cur_set out cursor_pdt) as
  15. begin
  16. --打开游标,由于定义游标时使用ref处理游标可以推迟到客户端
  17. open cur_set for select * from BookKindList;
  18. end;
  19. end;
  20.  
  21. /**使用过程测试定义的存储过程**/
  22. declare
  23. --定义游标类型的变量
  24. cur_set pkg_BookKinds.cursor_pdt;
  25. --定义行类型
  26. pdtrow BookKindList%rowtype;
  27. begin
  28. --执行存储过程
  29. pkg_BookKinds.proc_GetAllBookKind(cur_set);
  30. --遍历游标中的数据
  31. LOOP
  32. --取当前行数据存入pdtrow
  33. FETCH cur_set INTO pdtrow;
  34. --如果未获取数据就结束循环
  35. EXIT WHEN cur_set%NOTFOUND;
  36. --输出获取到的数据
  37. DBMS_OUTPUT.PUT_LINE (pdtrow.BookKindID||','||pdtrow.BookKindName);
  38. END LOOP;
  39. CLOSE cur_set;
  40. end;

 

  1. --创建包以游标的形式返回BookKindList的结果集
  2. create or replace package pkg_BookKindList is
  3. -- Author : geovindu
  4. type mycur is ref cursor;
  5. procedure fun_GetRecords(cur_return out mycur);
  6. end pkg_BookKindList;
  7.  
  8. create or replace package body pkg_BookKindList is
  9. -- Function and procedure implementations
  10. procedure fun_GetRecords(cur_return out mycur)
  11. is
  12. begin
  13. open cur_return for select * from BookKindList;
  14.  
  15. end fun_GetRecords;
  16.  
  17. end pkg_BookKindList;
  18.  
  19. declare
  20. --定义游标类型的变量
  21. cur_return pkg_BookKindList.mycur;
  22. --定义行类型
  23. pdtrow BookKindList%rowtype;
  24. begin
  25. --执行存储过程
  26. pkg_BookKindList.fun_GetRecords(cur_return);
  27. --遍历游标中的数据
  28. LOOP
  29. --取当前行数据存入pdtrow
  30. FETCH cur_return INTO pdtrow;
  31. --如果未获取数据就结束循环
  32. EXIT WHEN cur_return%NOTFOUND;
  33. --输出获取到的数据
  34. DBMS_OUTPUT.PUT_LINE (pdtrow.BookKindID||','||pdtrow.BookKindName);
  35. END LOOP;
  36. CLOSE cur_return;
  37. end;

  

 C# 3.5 调用查询:

  1. /// <summary>
  2. ///
  3. /// </summary>
  4. /// <param name="sender"></param>
  5. /// <param name="e"></param>
  6. private void Form3_Load(object sender, EventArgs e)
  7. {
  8. BindGridView();
  9. }
  10. /// <summary>
  11. ///
  12. /// </summary>
  13. private void BindGridView()
  14. {
  15. OracleConnection conn = new OracleConnection(connectionString);
  16. //ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString
  17. OracleCommand comm = new OracleCommand("pkg_BookKindList.fun_GetRecords", conn);
  18. comm.Parameters.Add("cur_return", OracleType.Cursor).Direction = ParameterDirection.Output;
  19. comm.CommandType = CommandType.StoredProcedure;
  20. DataSet ds = new DataSet();
  21. using (OracleDataAdapter da = new OracleDataAdapter(comm))
  22. {
  23.  
  24. da.Fill(ds);
  25. }
  26. this.dataGridView1.DataSource = ds.Tables[0].DefaultView;
  27.  
  28. }

  

  1. /// <summary>
  2. ///
  3. /// </summary>
  4. private void BindGridViewOther()
  5. {
  6. OracleConnection conn = new OracleConnection(connectionString);
  7. //ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString
  8. OracleCommand comm = new OracleCommand("pkg_BookKindList.fun_GetRecords", conn);
  9. comm.CommandType = CommandType.StoredProcedure;
  10. //定义参数,注意参数名必须与存储过程定义时一致,且类型为OracleType.Cursor
  11. OracleParameter cur_set = new OracleParameter("cur_return", OracleType.Cursor);
  12. //设置参数为输出类型
  13. cur_set.Direction = ParameterDirection.Output;
  14. //添加参数
  15. comm.Parameters.Add(cur_set);
  16. DataSet ds = new DataSet();
  17. using (OracleDataAdapter da = new OracleDataAdapter(comm))
  18. {
  19.  
  20. da.Fill(ds);
  21. }
  22. this.dataGridView1.DataSource = ds.Tables[0].DefaultView;
  23.  
  24. }

  

Oracle sql:

  1. ---某条记录的字段
  2. drop PROCEDURE proc_Select_BookKindName;
  3.  
  4. CREATE OR REPLACE PROCEDURE proc_Select_BookKindName(kind_id IN BookKindList.BookKindID%type) AS
  5. --声明语句段
  6. v_name varchar2(20);
  7. BEGIN
  8. --执行语句段
  9. SELECT o.BookKindName INTO v_name FROM BookKindList o where o.BookKindID=kind_id;
  10. dbms_output.put_line(v_name);
  11. EXCEPTION
  12. --异常处理语句段
  13. WHEN NO_DATA_FOUND THEN dbms_output.put_line('NO_DATA_FOUND');
  14. END;
  15.  
  16. --测试
  17. begin
  18. proc_Select_BookKindName(1);
  19. end;
  20.  
  21. ---一条记录
  22. --创建包:
  23. create or replace package pack_BookKindId is
  24. type cur_BookKindId is ref cursor;
  25. end pack_BookKindId;
  26. --创建存储过程
  27. create or replace procedure proc_curBookKindId(p_id in number,p_cur out pack_BookKindId.cur_BookKindId)
  28. is
  29. v_sql varchar2(400);
  30. begin
  31.  
  32. if p_id = 0 then
  33. open p_cur for select * from BookKindList;
  34. else
  35. v_sql := 'select * from BookKindList where BookKindID =: p_id';
  36. open p_cur for v_sql using p_id;
  37. end if;
  38. end proc_curBookKindId;
  39.  
  40. --测试查询一条记录存储过程
  41. -- Test statements here
  42. set serveroutput on
  43. declare
  44. v_id number := 1; --0 时,所有记录
  45. v_row BookKindList%rowtype; --注意这里是表名
  46. p_cur pack_BookKindId.cur_BookKindId;
  47. begin
  48. proc_curBookKindId(v_id, p_cur);
  49. loop
  50. fetch p_cur into v_row;
  51. exit when p_cur%notfound;
  52. DBMS_OUTPUT.PUT_LINE(v_row.BookKindName||'='||v_row.BookKindID);
  53. end loop;
  54. close p_cur;
  55. end;

  

ODP.NET:

  1. ///<summary>
  2. /// 查询所有记录
  3. ///</summary>
  4. ///<returns></returns>
  5. public List<BookKindListInfo> SelectBookKindListAll()
  6. {
  7. List<BookKindListInfo> list = new List<BookKindListInfo>();
  8. BookKindListInfo bookKindList = null;
  9. try
  10. {
  11. //定义参数,注意参数名必须与存储过程定义时一致,且类型为OracleType.Cursor
  12. OracleParameter cur_set = new OracleParameter("cur_return", OracleDbType.RefCursor);
  13. //设置参数为输出类型
  14. cur_set.Direction = ParameterDirection.Output;
  15. //OracleHelper.ExecuteReader(connectionString, CommandType.StoredProcedure, "pkg_Select_BookKindListAll.proc_Select_BookKindListAll", cur_set)
  16. using (OracleDataReader reader = OracleHelper.GetReader("pkg_Select_BookKindListAll.proc_Select_BookKindListAll", CommandType.StoredProcedure, cur_set))
  17. {
  18. while (reader.Read())
  19. {
  20. bookKindList = new BookKindListInfo();
  21. string s = reader["BookKindID"].ToString();
  22. bookKindList.BookKindID = (!object.Equals(reader["BookKindID"], null)) ? (decimal)reader["BookKindID"] : 0;
  23. bookKindList.BookKindName = (!object.Equals(reader["BookKindName"], null)) ? (string)reader["BookKindName"] : "";
  24. bookKindList.BookKindParent = (!object.Equals(reader["BookKindParent"], null)) ? (decimal)reader["BookKindParent"] : 0;
  25. list.Add(bookKindList);
  26.  
  27. }
  28. }
  29. }
  30. catch (OracleException ex)
  31. {
  32. throw ex;
  33. }
  34. return list;
  35. }
  36. ///<summary>
  37. /// 查询所有记录
  38. ///</summary>
  39. ///<returns></returns>
  40. public DataTable SelectBookKindListDataTableAll()
  41. {
  42. DataTable dt = new DataTable();
  43. try
  44. {
  45. //定义参数,注意参数名必须与存储过程定义时一致,且类型为OracleType.Cursor
  46. OracleParameter cur_set = new OracleParameter("cur_return", OracleDbType.RefCursor);
  47. //设置参数为输出类型
  48. cur_set.Direction = ParameterDirection.Output;
  49. //添加参数
  50. //comm.Parameters.Add(cur_set);
  51. using (DataTable reader = OracleHelper.GetTable("pkg_Select_BookKindListAll.proc_Select_BookKindListAll", CommandType.StoredProcedure, cur_set))
  52. {
  53. dt = reader;
  54.  
  55. }
  56. }
  57. catch (OracleException ex)
  58. {
  59. throw ex;
  60. }
  61. return dt;
  62. }

  

csharp: ODP.NET,System.Data.OracleClient(.net 4.0) and System.Data.OleDb读取Oracle g 11.2.0的区别的更多相关文章

  1. System.Data.Oracleclient需要Oracle客户端软件Version8.1.7或更高版本问题

    C#连接ORACLE报System.Data.Oracleclient需要Oracle客户端软件Version8.1.7或更高版本问题: 开始Webservice在32位系统ORACLE10g库中we ...

  2. vs2010:【“System.Data.OracleClient.OracleConnection”已过时】警告

    在oracle 安装目录下 找到 Oracle.DataAccess.dll添加引用,然后 using Oracle.DataAccess.Client;其他的都不用动,即可.连接字符串中 如有 用的 ...

  3. ORACLE 11.2.0.4 Single To Single Data Guard 安装 physical standby

    [root@ORACLE ~]# su - oracle [oracle@ORACLE ~]$ sqlplus / as sysdba . 查看主库归档模式: SQL> select log_m ...

  4. 11.2.0.4 ORA-15025 ORA-27041 IBM AIX RISC System/6000 Error: 13: Permission denied

    ASM device error ORA-27041 ORA-15025 ORA-15081 (Doc ID 1487475.1) 描述总结:数据库的alert中发现大量ORA-27041 ORA-1 ...

  5. 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 ...

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

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

  7. System.Data.OracleClient.OracleConnection已过时

    解决办法如下: 1.把原来的using System.Data.OracleClient;去掉 2.在oracle安装目录下找到Oracle.DataAccess.dll 添加引用:using Ora ...

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

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

  9. 微軟将弃用 System.Data.OracleClient

    http://www.cnblogs.com/WizardWu/archive/2010/05/17/1737009.html 微軟将从 .NET 4 以后的版本弃用 System.Data.Orac ...

随机推荐

  1. Web高级征程:《大型网站技术架构》读书笔记系列

    一.此书到底何方神圣? <大型网站技术架构:核心原理与案例分析>通过梳理大型网站技术发展历程,剖析大型网站技术架构模式,深入讲述大型互联网架构设计的核心原理,并通过一组典型网站技术架构设计 ...

  2. Leetcode 刷题计划

    Two Sum    21.4%    Medium Given an array of integers, return indices of the two numbers such that t ...

  3. 七天学会ASP.NET MVC (四)——用户授权认证问题

    小编应各位的要求,快马加鞭,马不停蹄的终于:七天学会 Asp.Net MVC 第四篇出炉,在第四天的学习中,我们主要了学习如何在MVC中如何实现认证授权等问题,本节主要讲了验证错误时的错误值,客户端验 ...

  4. Objective-C 原型模式 -- 简单介绍和使用

    用原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象. Prototype原型模式是一种创建型设计模式,Prototype模式允许一个对象再创建另外一个可定制的对象,根本无需知道任何如何创建 ...

  5. 《Spark大数据处理》—— 读后总结

    前几章 工作机制

  6. API调试工具推荐 - httpie

    API调试工具推荐 - httpie <HelloGitHub>第07期上面看到这个python项目,好东西 文档地址 但是安装的时候报错,google之后发现是个已知的bug,直接使用p ...

  7. ExtJs4之Grid详细

    ExtJs博客前奏 由于这段时间事情比较杂乱,博客就主要以项目中例子来说明编写. ExtJs4中的Grid非常强大,有展示,选中,搜索,排序,编辑,拖拽等基本功能,这篇博客我就这几个功能做写累述. 1 ...

  8. Android开发输入法遮盖屏幕底部按钮

    方法一: 在你的activity中的oncreate中setContentView之前写上这个代码: getWindow().setSoftInputMode(WindowManager.Layout ...

  9. eclipse将android项目生成apk并且给apk签名

    转载:http://www.cnblogs.com/tianguook/archive/2012/09/27/2705724.html 生成apk最懒惰的方法是:只要你运行过android项目,到工作 ...

  10. 【原创】开源.NET排列组合组件KwCombinatorics使用(二)——排列生成

           本博客所有文章分类的总目录:本博客博文总目录-实时更新 本博客其他.NET开源项目文章目录:[目录]本博客其他.NET开源项目文章目录 KwCombinatorics组件文章目录: 1. ...