当前位置:我的异常网» 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();
文章评论