• 调存储过程


        

    /////调用存储过程

        public pageList<MM> getshuju( int pageindex,int pagesize,string name )
            {
                if (string.IsNullOrWhiteSpace(name))
                    name = "";

                SqlCommand cmd = new SqlCommand("stu_ProcedureName", con);
                cmd.CommandType = CommandType.StoredProcedure;//执行执行的是存储过程

                SqlParameter pageidnexs = new SqlParameter("@pageindex", pageindex);
                SqlParameter pagesizes = new SqlParameter("@pageSize", pagesize);
                SqlParameter names = new SqlParameter("@name", name);
                SqlParameter counts = new SqlParameter("@count", SqlDbType.Int);
                counts.Direction = ParameterDirection.Output;//输出参数


                cmd.Parameters.Add(pageidnexs);
                cmd.Parameters.Add(pagesizes);
                cmd.Parameters.Add(names);
                cmd.Parameters.Add(counts);

                SqlDataAdapter da = new SqlDataAdapter(cmd);

                DataTable tb = new DataTable();
                da.Fill(tb);
                         
                var data = JsonConvert.SerializeObject(tb);
                var data2 = JsonConvert.DeserializeObject<List<MM>>(data);

                pageList<MM>  lsit= new pageList<MM>();
                lsit.count   = Convert.ToInt32(counts.Value);
                lsit.pageindex = pageindex;
                lsit.pagesize = pagesize;
                lsit.shuju = data2;


                return lsit;
            }

    嵌套类

     public class MM
        {
            public int newid { get; set; }
            public int id { get; set; }
            public string Names { get; set; }
            public int age { get; set; }
            public string adress { get; set; }

        }

        public class pageList<MM>
        {
            public int pageindex { get; set; }
            public int pagesize { get; set; }
            public int count { get; set; }
            public List<MM> shuju{get;set;}

        }

  • 相关阅读:
    推荐几款Silverlight Tools【转载】
    Emit Vs CodeDom
    Silverlight 中实现Service同步调用
    一个配置文件的Mapping
    Silverlight:获取ContentTemplate中的命名控件
    关于计划
    巧用异步委托解决异步并发问题
    我是如何学习NodeJs的 – 笔记1
    应用HttpHandler, Json, JQuery, ASP.Net UserControl等技术处理 Ajax 的解决方案
    关于程序员的那些事一个五年程序员的总结
  • 原文地址:https://www.cnblogs.com/yxlx/p/7879293.html
Copyright © 2020-2023  润新知