/// <summary> /// 执行SQL返回DataSet /// </summary> /// <param name="functor">事务执行器</param> /// <param name="sqlStr">被执行的SQL语句</param> /// <param name="parameterList">输入参数列表</param> /// <param name="timeOut">超时时间(单位:秒)</param> /// <returns>返回执行结果DataSet</returns> public static DataSet ExecuteDataSet(TransFunctor functor, string sqlStr, List <InputParameter> parameterList = null, int timeOut = 0) { try { if (functor == null) { return(ExecuteDataSet(sqlStr, parameterList, timeOut)); } IDbCommand cmd = CreateDbCommand(functor.Connection, sqlStr, parameterList, timeOut); cmd.Transaction = functor.Transaction; return(AdapterFillDataSet(cmd)); } catch (System.Exception ex) { DbHelper.WriteLog(ex, sqlStr, parameterList); throw; } }
/// <summary> /// 执行SQL语句,返回第一行第一列结果 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="functor">事务执行器</param> /// <param name="sqlStr">被执行的SQL语句</param> /// <param name="parameterList">输入参数列表</param> /// <param name="timeOut">超时时间(单位:秒)</param> /// <returns></returns> public static T ExecuteScalar <T>(TransFunctor functor, string sqlStr, List <InputParameter> parameterList = null, int timeOut = 0) { try { if (functor == null) { return(ExecuteScalar <T>(sqlStr, parameterList, timeOut)); } IDbCommand cmd = CreateDbCommand(functor.Connection, sqlStr, parameterList, timeOut); cmd.Transaction = functor.Transaction; object value = cmd.ExecuteScalar(); return(Parse <T>(value)); } catch (System.Exception ex) { DbHelper.WriteLog(ex, sqlStr, parameterList); throw; } }