Beispiel #1
0
        /// <summary>
        /// 摘要:执行无返回值不固定个数参数SQL语句(不带事务)
        /// </summary>
        /// <param name="conString">连接串名称,若默认连接串名称可以为null</param>
        /// <param name="sql">SQL语句</param>
        /// <param name="parameterNames">参数名称</param>
        /// <param name="parameterValues">参数值</param>
        /// <returns>影响行数</returns>
        public static int ExeParaSqlForNonQueryAccUp(string sql, List <string> parameterNames, List <object> parameterValues)
        {
            int iReturn = 0;
            List <OleDbParameter> cmdParms = new List <OleDbParameter>();

            if (parameterNames.Count > 1)
            {
                for (int i = 1; i < parameterNames.Count; i++)
                {
                    cmdParms.Add(new OleDbParameter(parameterNames[i], parameterValues[i]));
                }
                cmdParms.Add(new OleDbParameter(parameterNames[0], parameterValues[0]));
            }
            else
            {
                for (int i = 0; i < parameterNames.Count; i++)
                {
                    cmdParms.Add(new OleDbParameter(parameterNames[i], parameterValues[i]));
                }
            }


            iReturn = DbHelperACE.ExecuteSql(sql, cmdParms.ToArray());
            return(iReturn);
        }
Beispiel #2
0
        /// <summary>
        /// 摘要:执行返回数据集不固定个数参数SQL语句(不带事务)
        /// </summary>
        /// <param name="conString">连接串名称,若默认连接串名称可以为null</param>
        /// <param name="sql">SELECT SQL语句</param>
        /// <param name="parameterNames">参数名称</param>
        /// <param name="parameterValues">参数值</param>
        /// <returns>数据集</returns>
        public static DataSet ExeParaSqlForDataSetAccess(string sql, List <string> parameterNames, List <object> parameterValues)
        {
            DataSet dsResult = new DataSet();
            List <OleDbParameter> cmdParms = new List <OleDbParameter>();

            for (int i = 0; i < parameterNames.Count; i++)
            {
                cmdParms.Add(new OleDbParameter(parameterNames[i], parameterValues[i]));
            }
            dsResult = DbHelperACE.Query(sql, cmdParms.ToArray());

            return(dsResult);
        }