急,急,急~~~
StringBuilder StrSql = new StringBuilder();
StringBuilder strSql = new StringBuilder();
StrSql.AppendFormat("SELECT TOP {0} * FROM C_Work_Object WHERE ", Record_Per_Page.ToString());
StrSql.AppendFormat("(Obj_id NOT IN(SELECT TOP {0} Obj_id FROM C_Work_Object", "(Record_Per_Page*(nPage-1).tostring())");
if (timeStart != null || timeEnd != null)
{
StrSql.Append("where ");
strSql.Append("where ");
if (timeStart == null)
{
StrSql.AppendFormat("Obj_dotime < '{0}'", timeEnd.ToString());
strSql.AppendFormat("Obj_dotime < '{0}'", timeEnd.ToString());
}
else if (timeEnd == null)
{
StrSql.AppendFormat("Obj_dotime > '{1}'", timeStart.ToString());
strSql.AppendFormat("Obj_dotime > '{1}'", timeStart.ToString());
}
else
{
StrSql.AppendFormat("Obj_dotime between '{0}' and '{1}'", timeStart.ToString(), timeEnd.ToString());
strSql.AppendFormat("Obj_dotime between '{0}' and '{1}'", timeStart.ToString(), timeEnd.ToString());
}
}
StrSql.Append(" ORDER BY Obj_id DESC ");
strSql.Append(" ORDER BY Obj_id DESC ");
pdperson = pp.GetObjectBySql(StrSql.ToString() + strSql.ToString());
}
这个涉及到子查询,执行时报错:(’附近有语法错误 在HTML可视化工具中的结果是SELECT TOP 25 * FROM C_Work_Object WHERE (Obj_id NOT IN
(SELECT TOP (Record_Per_Page*(nPage-1).tostring())
Obj_id FROM C_Work_Objectwhere Obj_dotime between '2005
-10-1 0:00:00' and '2006-10-1 0:00:00' ORDER BY Obj_id
DESC where Obj_dotime between '2005-10-1 0:00:00' and
'2006-10-1 0:00:00' ORDER BY Obj_id DESC 哪位大狭帮忙指点一下啊??什么地方不正确啊???
------解决方案--------------------你把sql脚本在数据库中执行,看看报什么错
------解决方案--------------------把你的SQL放到查询分析器中一查,你就知道什么原因了,
这个对你解决问题有很大的帮助,我也这样走过来的。