zoukankan      html  css  js  c++  java
  • asp.net数据库操作技巧例子,改变sql语句

    public DataTable dt(string aid,string sid,string lx,string dtt,string key,string big)
        {//根据传来的地区分类,大分类,小分类,读取info数据库的内容
            //下面的镶套判断本来没必要的,呵呵,只是我用了好久才弄完,纪念下
            
             String SQL ="select * from [info] where sh=0" ;
            if (aid != null)
            {//如果地区ID存在
                 SQL += " and [aid]=" + aid + "";
                if (sid != null)
                {//小类ID 也 存在
                     SQL += " and [sid]=" + sid + "";
                 }
                if (lx != null)
                {//如果类型存在
                         SQL += " and [lx]='" + lx + "'";
                 }
             }
            if (sid != null)
            {//如果小类ID存在
                if(aid == null)
                 SQL += " and [sid]=" + sid + "";
                if (lx != null)
                {//如果类型存在
                    if (aid == null)
                         SQL += " and [lx]='" + lx + "'";
                 }
             }
            if (lx != null)
            {//如果类型存在
                if (aid == null&&sid==null)
                     SQL += " and [lx]='" + lx + "'";
             }
            if (dtt != null)
            {
                 SQL += " and [dtimme]>= #"+dtt+"#";
             }
            if (big != null)
            {
                 SQL += " and [bid]=" + big + "";
             }
            if (key != null)
            {
                 SQL += " and infotext like '%" + key + "%' or aaa   like '%" + key + "%' or title   like '%" + key + "%'";
             }
             OleDbConnection con = new OleDbConnection(connstring);
             OleDbDataAdapter oda = new OleDbDataAdapter();
             oda.SelectCommand = new OleDbCommand(SQL, con);
             DataSet ds = new DataSet();
             oda.Fill(ds,"thc");
            return ds.Tables["thc"];
         }
  • 相关阅读:
    解决类似 /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found 的问题
    qemu vm setup network(ssh) with buildroot
    C: 当字符数组首指针转化成char *指针,sizeof(*ptr)不为array的size
    C 利用strtok, feof 截取字符串
    LINUX C: 获取本地指定网卡的IP地址
    C语言比较好的风格梳理
    perf-perf stat用户层代码分析
    内核调试-perf introduction
    内核调试-ftrace introduction
    【原创】VB6.0应用程序安装包的生成(Setup Factory 9.0制作安装包的方法)
  • 原文地址:https://www.cnblogs.com/sshh/p/1368919.html
Copyright © 2011-2022 走看看