zoukankan      html  css  js  c++  java
  • 多条件Sql语句

    public static string doQuery()
            {
                bool hasWhere = false;
                StringBuilder sql = new StringBuilder("select * from table");
                if (true)
                {
                    hasWhere = appendWhereIfNeed(sql, hasWhere);
                    sql.AppendLine("FNumber between ' 工号文本框1内容 ' and '工号文本框2内容 '");
                }
                if (true)
                {
                    hasWhere = appendWhereIfNeed(sql, hasWhere);
                    sql.AppendLine("FNumber2 between ' 工号文本框1内容 ' and '工号文本框2内容 '");
                }
                if (true)
                {
                    hasWhere = appendWhereIfNeed(sql, hasWhere);
                    sql.AppendLine("FNumber3 between ' 工号文本框1内容 ' and '工号文本框2内容 '");
                }
                return sql.ToString();
                 
            }

            private static bool appendWhereIfNeed(StringBuilder sql, bool hasWhere)
            {
                if (hasWhere == false)
                {
                    sql.AppendLine(" where ");
                    hasWhere = true;
                }
                else
                {
                    sql.AppendLine(" and ");

                }
                return hasWhere;

            }

  • 相关阅读:
    房地产英语 Real estate词汇
    自制Flash FLV视频播放器
    .net反编译工具Reflector下载
    JQUery插件thickbox
    50 Great Photoshop Tutorials for Clever Beginners
    AspNet中你或许不知道的技巧(转)
    常用的设计网站(收藏)
    35 Green and Earthy Photoshop Effects
    使用 ASP.NET 2.0 增强网站的安全性
    asp.net中实现登陆的时候用SSL
  • 原文地址:https://www.cnblogs.com/yk25com/p/2672345.html
Copyright © 2011-2022 走看看