C# 通过ado.net 访问oracle
1.安装ODP(oracle data provider)
2.然后在项目中引用 Oracle.DataAccess程序集
3.接着
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
4.然后编写程序和ado.net方位sqlserver 差别不大了,就是利用下面的对象进行编程,当然,因为oracle和sqlserver有很多地方不一样,所以细节存在很大差异。
OracleConnection
OracleCommand
OracleParameter
OracleDataReader
OracleDataAdapter
5. 实例
例1: 根据部门ID 获取部门名称
string oradb = "Data Source=TESTASM;User Id=hr;Password=hr;";
OracleConnection conn = new OracleConnection(oradb);
conn.Open();
OracleParameter param = new OracleParameter();
param.OracleDbType = OracleDbType.Decimal;
param.Value = textBox1.Text;
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.Parameters.Add(param);
cmd.CommandText = "select department_name from departments where department_id = :1";
if(dr.Read())
{
textBox1.Text = dr.GetString(
相关文档:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient; ......
---------------------------------------
Asp.Net,C#,SQL,JS,WCF,AJAX,工作流,WPF,MVC,LINQ,设计模式(架构)等技术讨论
“ASP.NET(C#)Fans” QQ群:96877690
---------------------------------------
不管是J2SE、J2EE还是J2ME敬请加入!Eclipse、NetBeans
Java交流QQ高级群扩招:96878255 ......
C#中操作Oracle时的SQL语句参数的用法
OracleTransaction myTrans ;
conn.Open();
myTrans =conn.BeginTransaction(IsolationLevel.ReadCommitted) ......
之前不太喜欢C#,无意中发现linq,用来实现排序是如此简单,所以又用C#写了遍发牌程序
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
&nb ......
---------------------------------------
Asp.Net,C#,SQL,JS,WCF,AJAX,工作流,WPF,MVC,LINQ,设计模式(架构)等技术讨论
“ASP.NET(C#)Fans” QQ群:96877690
---------------------------------------
不管是J2SE、J2EE还是J2ME敬请加入!Eclipse、NetBeans
Java交流QQ高级群扩招:96878255 ......