string constr oracle 连接,C#连接并操作Oracle数据库

C#连接并操作Oracle数据库

C#连接并操作Oracle数据库

1.NuGet安装Oracle.ManagedDataAccess

2.引用

using Oracle.ManagedDataAccess;

using Oracle.ManagedDataAccess.Types;

using Oracle.ManagedDataAccess.Client;

3.Action

public OperationResult InsertDate(string order)

{

//String constr = “User ID=USER1;Password=pass;Data Source=(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST=1.1.1.1)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=DBDEV)))”;

string constr = System.Configuration.ConfigurationManager.AppSettings[“DBOA”];

OracleConnection con = new OracleConnection(constr);

//System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(constr);

con.Open(); //建立连接,打开数据库

OperationResult returnResult = new OperationResult();

try

{

returnResult.Errors.Add(“成功连接数据库!”);

var id = “1”;

var pass = “2”;

string sql = “insert into temp (fd_B,status) values (‘B5′,’5’)”;

//string sql = “select count(*) from spare_part_temp”;

// SqlCommand com = new SqlCommand(sql, con);

OracleCommand oc = new OracleCommand(sql, con);

int result = oc.ExecuteNonQuery();

JeffSoft.Logger.Error(string.Format(“成功读取{0},条记录”, result));

//int Succnum = com.ExecuteNonQuery();

//结果集保存

con.Close();

return returnResult;

}

catch (Exception)

{

throw;

}

finally

{

con.Close();

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值