zoukankan      html  css  js  c++  java
  • 调存储过程

        

    /////调用存储过程

        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;}

        }

  • 相关阅读:
    (OK) angular2-data-table is a Angular2 component for presenting large and complex data.
    Table pagination and Search bar in Angular2
    Angular 2 Tutorial: Create a CRUD App with Angular CLI and TypeScript
    Angular 2 CRUD application using Nodejs
    kernel 3.10内核源码分析--BUG_ON流程
    Protecting Routes using Guards in Angular 2
    Angular 2 User Registration and Login Example & Tutorial
    dmidecode
    (half OK) 在VirtualBox中运行 cm-13-kiwi (华为 荣耀 5X)
    Linux基金会宣布成立OpenSDS组织,应对存储云化转型
  • 原文地址:https://www.cnblogs.com/yxlx/p/7879293.html
Copyright © 2011-2022 走看看