首页 > 数据库 > Access > 正文

datalist分页(cj168.DataAccess.MagsDB中的2个方法)

2024-09-07 19:04:55
字体:
来源:转载
供稿:网友

商业源码热门下载www.html.org.cn

public icollection getsearchresult(string txtsearch, int startindex, int pagesize)
        {
            
            sqlconnection myconnection = new sqlconnection(configurationsettings.appsettings["connectionstring"]);
            sqldataadapter mycommand = new sqldataadapter("getsearchresult", myconnection);
            
            mycommand.selectcommand.commandtype = commandtype.storedprocedure;
            
            sqlparameter parametertxtsearch = new sqlparameter("@txtsearch", sqldbtype.varchar, 255);
            parametertxtsearch.value = txtsearch;
            mycommand.selectcommand.parameters.add(parametertxtsearch);

            dataset mydataset = new dataset();
        
            mycommand.fill(mydataset, startindex, pagesize, "searchresult");
            
            return mydataset.tables["searchresult"].defaultview;

        }


        public int getsearchresultcount(string txtsearch)
        {
            int intcount ;
            intcount = 0;
            

            sqlconnection myconnection = new sqlconnection(configurationsettings.appsettings["connectionstring"]);
            sqlcommand mycommand = new sqlcommand("getsearchresultcount", myconnection);
            mycommand.commandtype = commandtype.storedprocedure;

            sqlparameter parametertxtsearch = new sqlparameter("@txtsearch", sqldbtype.varchar, 255);
            parametertxtsearch.value = txtsearch;
            mycommand.parameters.add(parametertxtsearch);

            myconnection.open();
            sqldatareader dr =mycommand.executereader();
            
            if(dr.read())
            {
                intcount = int32.parse(dr["co"].tostring());
            }
            else
            {
                intcount = 0;
            }
            
            dr.close();
            return intcount;

        }
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表