zoukankan      html  css  js  c++  java
  • Vs调用分页存储过程

    /// <summary>
            /// 显示+分页+模糊查询
            /// </summary>
            /// <param name="pageindex"></param>
            /// <param name="pagesize"></param>
            /// <param name="name"></param>
            /// <param name="count"></param>
            /// <returns></returns>
            public List<Model.UserInfo> SelAllpage(int pageindex,int pagesize,string name,out int count)
            {
                conn.Open();
                SqlCommand command = new SqlCommand("upage",conn);------"upage"为分页存储过程的名称
                command.CommandType = CommandType.StoredProcedure;
                SqlParameter[] p =
                {
                    new SqlParameter ("@pageindex",SqlDbType.Int),
                    new SqlParameter ("@pagesize",SqlDbType.Int),
                    new SqlParameter ("@count",SqlDbType.Int),
                    new SqlParameter ("@name",SqlDbType.VarChar,50),
                };
                p[0].Value = pageindex;
                p[1].Value = pagesize;
                p[2].Direction = ParameterDirection.Output;
                p[3].Value = name;
                command.Parameters.AddRange(p);
                command.ExecuteNonQuery();
                count = Convert.ToInt32(p[2].Value);
                SqlDataAdapter apter = new SqlDataAdapter(command);
                DataTable dt = new DataTable();
                apter.Fill(dt);
                List<UserInfo> list = new List<UserInfo>();
                for (int i = 0; i < dt.Rows.Count;i++ )
                {
                    UserInfo u = new UserInfo();
                    u.ID = Convert.ToInt32(dt.Rows[i]["ID"]);
                    u.UserName = dt.Rows[i]["UserName"].ToString();
                    u.UserPwd = dt.Rows[i]["UserPwd"].ToString();
                    u.RealName = dt.Rows[i]["RealName"].ToString();
                    u.CreateTime = Convert.ToDateTime(dt.Rows[i]["CreateTime"]);
                    list.Add(u);
                }
                return list;
                   
            }
  • 相关阅读:
    附件下载遇到 ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION 错误
    Javascript模块编程&jQuery插件开发学习笔记
    网站推荐
    分布式服务下Quartz任务变为EREOR分析及解决
    Quartz任务监听器
    定时任务框架Quartz基本使用
    2020年CKA考试分享
    vue-element-loading 动态插件
    pycharm之常用插件
    PHP开源项目之YOURLS
  • 原文地址:https://www.cnblogs.com/huosanpie/p/9978947.html
Copyright © 2011-2022 走看看