问题如下:
动态查询时,没有LIKE语句时,是正常的。但加入LIKE时就查不到了,而SQL语句在ACCESS中直接跑时,是可以查出数据的,为什么呢?
程序代码:
 public DataSet queryList(string strSql,OleDbConnection dbconn)
        {
            DataSet ds = null;
            try
            {
                Console.WriteLine("strSql-->" + strSql);                OleDbDataAdapter da = new OleDbDataAdapter(strSql, dbconn);
                ds = new DataSet();
                da.Fill(ds,CommonConstant.DB_DSFillName);                this.CloseDBConn(dbconn);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }            return ds;
        }
打印出的SQL:
select xmid,xmbh,xmmc,xfsj,wcsj,isok,bz from jx_db_task where 1=1 and xmmc like '*内蒙古*' and Format(xfsj,'yyyy-mm-dd 00:00:00') >= Format('2009-2-2 19:45:31','yyyy-mm-dd 00:00:00') and Format(xfsj,'yyyy-mm-dd 00:00:00') <= Format('2013-2-3 19:45:31','yyyy-mm-dd 00:00:00') and Format(wcsj,'yyyy-mm-dd 00:00:00') >= Format('2008-2-4 19:45:31','yyyy-mm-dd 00:00:00') and Format(wcsj,'yyyy-mm-dd 00:00:00') <= Format('2013-2-7 19:45:31','yyyy-mm-dd 00:00:00')accesssqlC# WINFORM