??? ?? 2016-07-09 07:41 采纳率: 100%
浏览 775
已采纳

多条件查询 没值 多条件查询 没值

public static List getAllplanFine(string startime,string
endtime,string productname,string equipment, string properson)
{

List dqt = new List();
string sql = @"select *from [Plan] p inner join [Week] w on p.planid=w.pid where 1=1";
List items = new List();
if (startime.Length > 0)
{
sql += " and startime = @startime";
items.Add(new SqlParameter("@startime", startime ));
}

        if (endtime.Length > 0)
        {
            sql += " and endtime = @endtime";
            items.Add(new SqlParameter("@endtime",  endtime ));
        }
        if (equipment.Length > 0)
        {
            sql += " and equipment= @equipment";
            items.Add(new SqlParameter("@equipment", equipment));
        }

        if (productname.Length > 0)
        {
            sql += " and productname = @productname";
            items.Add(new SqlParameter("@productname", productname));
        }
        if (properson.Length > 0)
        {
            sql += " and properson= @properson";
            items.Add(new SqlParameter("@properson", properson));
        }

        DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.ConnectionString, CommandType.Text, sql, items.ToArray());
        //dataset yeyou talbes
        //datable DataRow in dt.Rows 
        if (ds.Tables.Count > 0)
        {
            DataTable dt = ds.Tables[0];
            foreach (DataRow item in dt.Rows)
            {
                Plan q = new Plan();
                q.planid = int.Parse(item["planid"].ToString());
                q.productname = item["productname"].ToString();
                q.equipment = item["equipment"].ToString();
                q.functionalmodule = item["functionalmodule"].ToString();
                q.partscode = item["partscode"].ToString();
                q.partsimage = item["partsimage"].ToString();

                                    多条件查询 没值 为空
  • 写回答

1条回答 默认 最新

  • threenewbee 2016-07-09 14:22
    关注

    SqlHelper.ExecuteDataset
    这个本身有没有错误,在里面下断点调试下

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度