//取得查询条件
txtQueryCondition.Value="";
string condition="";
txtNavigatePage.Value="block";
//分类
string categoryId=CommonMethod.GetRequest(this,"categoryId");
if(categoryId.Length>0)
{
// this.txtCategoryId.Value=categoryId;
if(categoryId.IndexOf(",")>0)//因为URLRewriter请求页面/Search/product_3403.html形式时,会造成categoryId重复两次
{
categoryId=categoryId.Substring(0,categoryId.IndexOf(","));
}
condition+=" and ( A.industryType1='"+categoryId+"' or A.industryType2='"+categoryId+"' or A.industryType3='"+categoryId+"' )";
}
else
{
this.dtCategory.Visible=false;
}
string province =CommonMethod.GetRequest(this,"province");
if(province.Length>0)
{
condition+=" and A.province='"+province+"' ";
}
string city =CommonMethod.GetRequest(this,"city");
if(city.Length>0)
{
condition+=" and A.city='"+city+"' ";
}
string businesstype =CommonMethod.GetRequest(this,"businesstype");
if(businesstype.Length>0)
{
condition+=" and A.businesstype = '"+businesstype+"' ";
}
string foundDate =CommonMethod.GetRequest(this,"founddate");
if(foundDate.Length>0)//发布时间
{
condition+=" and A.Creationtime>getdate()-"+foundDate;
}
string keyword =CommonMethod.GetRequest(this,"keyword");
if(keyword.Length>0)
{
condition+=" and contains(A.OfferTitle , '"+keyword+"') ";
this.txtKeyword.Value=keyword;
} string keywords =CommonMethod.GetRequest(this,"keywords");
if(keywords.Length>0)
{
condition+=" and contains(A.OfferTitle , '"+keywords+"') ";
this.txtKeyword.Value=keywords;
}
//每页数量
int pageSize=10;
if(CommonMethod.GetRequest(this,"pageSize").Length>0)
{
pageSize=System.Int16.Parse(CommonMethod.GetRequest(this,"pageSize"));
}
this.AspNetPager1.PageSize=pageSize;
this.txtPageSize.Value=pageSize.ToString(); string showType="2";
if(CommonMethod.GetRequest(this,"showType").Length>0)
{
showType=CommonMethod.GetRequest(this,"showType");
}
this.txtShowType.Value=showType;
// string sql="select A.*,B.gid,B.zoneid from t_offer A left join t_lavauser B on (A.CreatedByUserId=B.lavauserId) where A.IsDeleted=0 and A.IsBuy=0"; //string osql = " group by a.CreationTime ";
sql+=condition;
//sql += osql;
DataSet ds=ServiceInterfaces.CommonService.GetDataPage(sql,this.AspNetPager1.CurrentPageIndex,this.AspNetPager1.PageSize,out ResultRecordCount);
遇到的问题:如何在string sql中加入按时间addtime排序呢?用order by 好像不行,谢谢帮忙,谢谢
解决方案 »
- 相同的网站问题web.config没问题
- ObjectStateManager 中已存在具有同一键的对象。现有对象处于 Modified 状态。只有在该对象处于 added 状态后,才能再次将它添加到
- 还是面试题分部多了 将一个字符串转换为INT类型的数组。写一个手机号码的正则表达式。获取机器当前时间,格式为1980/02/1
- 如何推广个人写的产品
- ASP.NET简单问题,做一个链接能不能到cs文件里
- 问了有问:环境:VS2005,问题:如何取消iframe的水平滚动条?
- VS2010 的工具箱中没有控件,重新安装了也不行,怎么办啊?
- 求助:开发环境
- MVC 中@Html.TextArea问题
- kane (城里人) 接分,ASPnetMenu1.04的注册码
- 使用虚拟空间连不到数据库了
- 请教editcommandcolumn
order by A.Creationtime 不行吗?
if(foundDate.Length>0)//发布时间
{
condition+=" and A.Creationtime>getdate()-"+foundDate;
}这里出的问题吧
错误是:除非另外还指定了 TOP 或 FOR XML,否则,ORDER BY 子句在视图、内联函数、派生表、子查询和公用表表达式中无效。除非另外还指定了 TOP 或 FOR XML,否则,ORDER BY 子句在视图、内联函数、派生表、子查询和公用表表达式中无效。
求救,谢谢