c 连接oracle 通用类,c#操作oracle,有没有相仿sqlhelp之类的通用操作类(6)

当前位置:我的异常网» C# » c#操作oracle,有没有相仿sqlhelp之类的通用操作类

c#操作oracle,有没有相仿sqlhelp之类的通用操作类(6)

www.myexceptions.net  网友分享于:2013-08-26  浏览:149次

oracleCommand.Parameters.Add((OracleParameter)myParams[i]);

}

using (OracleDataAdapter da = new OracleDataAdapter(oracleCommand))

{

int returnValue = da.Fill(ds);

if (returnValue < 0)

throw new Exception("存储过程执行错误:" + (returnValue >= -14 ?

((StoreProcReturn)returnValue).ToString() : "ErrCode:" + returnValue));

return ds;

}

}

catch (Exception ex)

{

throw ex;

}

}

}

///

/// 执行一个非查询式的存贮过程

///

/// 存贮过程名称

/// 所有属性值

/// 存储过程return值

public int ExecNonQueryStoredProcedure(string proceName, ref object[] myParams)

{

if (proceName == null || proceName == string.Empty)

{

throw new Exception("抱歉,存贮过程名称为空...");

}

using (oracleConnection = this.GetOracleConnection())

{

if (oracleConnection == null)

throw new Exception("抱歉,数据库连接没有初始化...");

try

{

if (oracleConnection.State == System.Data.ConnectionState.Closed)

oracleConnection.Open();

oracleCommand = oracleConnection.CreateCommand();

oracleCommand.CommandType = CommandType.StoredProcedure;

oracleCommand.CommandText = proceName;

if (myParams != null)

{

for (int i = 0; i < myParams.Length; i++)

oracleCommand.Parameters.Add((OracleParameter)myParams[i]);

}

int returnValue = oracleCommand.ExecuteNonQuery();

if (returnValue < 0)

throw new Exception("存储过程执行错误:" + (returnValue >= -14 ?

((StoreProcReturn)returnValue).ToString() : "ErrCode:" + returnValue));

return returnValue;

}

catch (Exception ex)

{

throw ex;

}

}

}

public void Dispose()

{

this.connectionString = null;

if (this.oracleCommand != null)

this.oracleCommand.Dispose();

if (this.oracleConnection != null)

this.oracleConnection.Dispose();

文章评论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值