免费邮箱 |加入收藏 | 会员中心 | 我要投稿 | RSS
您当前的位置:首页 > .NET专区 > ASP.NET应用

ado.net快速上手实践篇(一)

时间:2011-05-21 10:43:51  来源:站内  作者:潘春会

        }

        public override int Insert(string sqlStr, CommandType cmdType, List<DbParameter> listParams)
        {
            object obj = ExecuteScalar(sqlStr, cmdType, listParams);
            int id = obj == null ? 0 : int.Parse(obj.ToString());
            return id;
        }

        /// <summary>
        /// 批量插入
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="batchSize"></param>
        /// <param name="copyTimeout"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        public override bool BatchInsert(string tableName, int batchSize, int copyTimeout, DataTable dt)
        {
            return this.CurrentDbOperation.ExecuteBatchInsert(tableName, batchSize, copyTimeout, dt);
        }

        #endregion

        #region delete

        public override int Delete(string sqlStr)
        {
            return CommitSql(sqlStr, CommandType.Text, null);
        }

        public override int Delete(string sqlStr, CommandType cmdType, List<DbParameter> listParams)
        {
            return CommitSql(sqlStr, cmdType, listParams);
        }

        #endregion

        #region update

        public override int Update(string sqlStr)
        {
            return CommitSql(sqlStr, CommandType.Text, null);
        }

        public override int Update(string sqlStr, CommandType cmdType, List<DbParameter> listParams)
        {
            return CommitSql(sqlStr, cmdType, listParams);
        }

        #endregion

        #region commit and execute sql

        private int CommitSql(string sqlStr, CommandType cmdType, List<DbParameter> listParams)
        {
            return this.CurrentDbOperation.ExecuteNonQuery(sqlStr, cmdType, listParams);
        }

        #endregion

        #region  dbparameter

        public DbParameter CreateParameter(string paraName, object paramValue)
        {
            return this.CurrentDbOperation.CreateDbPrameter(paraName, paramValue);
        }

        public List<DbParameter> CreateParameterList(string[] paraNames, object[] paramValues)
        {
            List<DbParameter> listParams = new List<DbParameter>();
            try
            {
                if (paraNames.Length != paramValues.Length)

来顶一下
返回首页
返回首页
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表
推荐资讯
如何找出DHCP地址池里未使用的IP地址
如何找出DHCP地址池里
国内常用的DNS列表
国内常用的DNS列表
Linux邮件服务器软件比较
Linux邮件服务器软件比
学用纯CSS打造可折叠树状菜单
学用纯CSS打造可折叠树
相关文章
栏目更新
栏目热门