protected void BindData(string where)
{
int count = 0;
string strSql = "select count(1) from ibt1 T0 left  join oitm T2 ON T2.itemcode=T0.itemcode left join owtr T3 ON T3.DocNum=T0.BaseEntry left join oibt T4 ON T4.ItemCode=T0.ItemCode" + where;
DataSet ds = new DataSet();
ds = WangWei.DBUtility.DbHelperSQLSAP.Query(strSql); count = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString());
ds = WangWei.DBUtility.DbHelperSQLSAP.GetListPage(" select T0.itemcode  ,T0.itemName ,T2.FrgnName ,T2.SuppcatNum  ,T0.Quantity,T0.BatchNum ,  T4.PrdDate  ,T4.ExpDate  ,T0.Whscode,T0.BaseEntry,T0.Direction,T0.DocDate  from ibt1 T0 left  join oitm T2 ON T2.itemcode=T0.itemcode left join owtr T3 ON T3.DocNum=T0.BaseEntry left join oibt T4 ON T4.ItemCode=T0.ItemCode and T4.Whscode=T0.Whscode and T4.BatchNum=T0.BatchNum where  T0.Direction='0' and T0.whscode<>'01'  and T3.Filler='01' order by T0.BaseEntry ,T0.itemcode asc  "
+ where, pager.CurrentPageIndex, pager.PageSize, "itemcode ", "itemcode asc");

解决方案 »

  1.   

    单步调一下 看where的值是什么 拼在一起的sql语句直接执行看不错不
      

  2.   

    你怎么知道在sqlserver执行正常?你确定在程序里执行的sql语句确实和你在SqlServer里执行的是同一个语句?
    建议在执行sql的语句上下断点,查看执行的sql是否确实正确,必要的时候把将在程序里执行的sql语句复制到Sql查询分析器或者SQL Server Management Studio Express里面执行看看。string strSql = "select count(1) from ibt1 T0 left  join oitm T2 ON T2.itemcode=T0.itemcode left join owtr T3 ON T3.DocNum=T0.BaseEntry left join oibt T4 ON T4.ItemCode=T0.ItemCode" + where;
    这样构造出来的sql语句很可能出错,因为你无法保证字符串where的前面有空格。
      

  3.   

    where 能用吗 ?试一试换个变量
      

  4.   

    调试看看strSql ,where值什么放在order之前
    "and T3.Filler='01'" +where+" order by T0.BaseEntry ,T0.itemcode asc  "
      

  5.   

    跟踪strSql 放到SQL服务器上执行看看吧
      

  6.   

    我以前也发生过类似的事情,是因为某字段长度受限导致的。例如你name字段允许20长度,而你却要输入30个长度。查查。
      

  7.   

    你使用了count函数就必须使用group by进行分组
      

  8.   

    你怎么写了两个where啊
    where  T0.Direction='0' and T0.whscode<>'01'  and T3.Filler='01' order by T0.BaseEntry ,T0.itemcode asc  "+ where