sql = "select * from Commodity";
        hs = new Hashtable();
        if (txt_name.Text.Trim() != "")
        {
            sql += " where Name like @Name";
            hs.Add("@Name", "%" + txt_name.Text.Trim() + "%");
        }
   一、通过字符串操作,查看之前是否有Where
        if (txt_jgup.Text.Trim() != "")
        {
            if (sql.Contains("where"))
                sql += " and Price >= @Priceup";
            else
                sql += " where Price >= @Priceup";
            hs.Add("@Priceup", txt_jgup.Text.Trim());
        }

  二、通过标记变量;
        if (txt_numup.Text.Trim() != "")
        {
            )
                sql += " and Stock >= @Stockup";
            else
                sql += " where Stock >= @Stockup";       count++;
            hs.Add("@Stockup", txt_numup.Text.Trim());
        }

  三、拼接不参与搜索的用,1=1等替代     if (txt_name.Text.Trim() != "")
        {
            sql += " where Name like @Name";
            hs.Add("@Name", "%" + txt_name.Text.Trim() + "%");
        }
        else
        {
            sql += " where 1=1";
        }
        if (txt_numup.Text.Trim() != "")
        {
                sql += " and Stock >= @Stockup";
            hs.Add("@Stockup", txt_numup.Text.Trim());
        }else
        {
            sql += " and 2=2";
        }

组合后的分页查询语句需要添加,上面生成的语句,限定Select查询范围

WebForm 分页、组合查询--2017年1月5日的更多相关文章

  1. webform:分页组合查询

    一个简单的分页组合查询页面 /// <summary> /// 查询方法 /// </summary> /// <param name="tsql"& ...

  2. ASP.NETMVC4 分页组合查询解决方法

    本人新手刚在webform转到mvc   像linq  ef啥的,都是不会的不行不行的,不会就问群友,找资料 今天本屌遇到了一个分页组合查询的问题,解决了2个小时,把代码共享给大家 话不多话,直接上代 ...

  3. Linq组合查询与分页组合查询结合

    1.组合查询 <div>姓名:<asp:TextBox ID="T1" runat="server"></asp:TextBox& ...

  4. 【2017-06-02】Linq高级查询,实现分页组合查询。

    1.以XXX开头 2.以XXX结尾 3.模糊查询 4.求个数 5.求最大值 6.求最小值 7.求平均值 8.求和 9.升序 10.降序 11.分页 Skip()跳过多少条 Take()取多少条 12. ...

  5. 【2017年9月10日更新】ABP配套代码生成器(ABP Code Generator)帮助文档,实现快速开发

    ABP代码生成器介绍 ABP Code Generator 针对abp这个框架做了一个代码生成器,功能强大.分为两大功能点,一个是数据层,一个是视图层. 数据服务层:通过它,可以实现表设计.领域层初始 ...

  6. 2017年1月1日 App Store中的所有应用都必须启用 App Transport Security安全功能

    2017年1月1日 App Store中的所有应用都必须启用 App Transport Security安全功能,否则极有可能被拒! 在WWDC 2016开发者大会上,苹果宣布了一个最后期限:到20 ...

  7. 2017年10月31日结束Outlook 2007与Office 365的连接

    2017 年10月31日 ,微软即将推出 Office 365中Exchange Online邮箱将需要Outlook for Windows的连接,即通过HTTP Over MAPI方式,传统使用R ...

  8. 猖獗的假新闻:2017年1月1日起iOS的APP必须使用HTTPS

    一.假新闻如此猖獗 刚才一位老同事 打电话问:我们公司还是用的HTTP,马上就到2017年了,提交AppStore会被拒绝,怎么办? 公司里已经有很多人问过这个问题,回答一下: HTTP还是可以正常提 ...

  9. [转载]Ubuntu17.04(Zesty Zapus)路线图发布:2017年4月13日发布

    Canonical今天公布了Ubuntu 17.04(Zesty Zapus)操作系统的发布路线图,该版本于今年10月24日上线启动,toolchain已经上传且首个daily ISO镜像已经生成.面 ...

随机推荐

  1. [LeetCode] Copy List with Random Pointer 拷贝带有随机指针的链表

    A linked list is given such that each node contains an additional random pointer which could point t ...

  2. [LeetCode] Interleaving String 交织相错的字符串

    Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example, Given: s1 ...

  3. sstream

    sstream用法 #include<iostream> #include<sstream> #include<string> using namespace st ...

  4. IOS跑马灯效果,实现文字水平无间断滚动

    ViewController.h #import <UIKit/UIKit.h> @interface ViewController : UIViewController{ NSTimer ...

  5. oracle db link的查看创建与删除

    1.查看dblink select owner,object_name from dba_objects where object_type='DATABASE LINK'; 或者 select * ...

  6. FREEBSD手工配置网络

    在FreeBSD系统中,网络能力十分重要,对于一个标准的FreeBSD系统,至少要有一个网络界面以便与其他计算机通信.最常见的网络界面为以太网卡.此外FreeBSD也支持Token Ring和FDDI ...

  7. svn报错cleanup failed–previous operation has not finished; run cleanup if it was interrupted的解决办法

    今天在svn提交的时候它卡顿了一下,我以为已经提交完了,就按了一下,结果就再也恢复不了,也继续不了了... 报错 cleanup failed–previous operation has not f ...

  8. JSPatch 使用

    1.JSPatch 准备 地址:https://github.com/bang590/JSPatch 框架:libz.1.tbd , JavaScriptCore.framework 2.cocosp ...

  9. Xamarin.ios 目录结构

    1.Resources: 文件夹存放应用程序所. 2.AppDelegate.cs: 主要的应用程序类别(class) ,并接听 系统事件及相对应的事件处理. 3.Entitlements.plist ...

  10. Python Day20

    Django 表操作 1.基本操作 # 增 # # models.Tb1.objects.create(c1='xx', c2='oo') 增加一条数据,可以接受字典类型数据 **kwargs # o ...