--改为:
string strSqlNewsContent = "select ProductID,ProductContent from (select ProductID,ProductTitle as ProductContent from ViewProducts union select ProductID,ProductTitle from ViewProductZ union select ProductID,ProductTitle from ViewProductH) a where ProductContent like '%"+SearchKey+"%'";

解决方案 »

  1.   

    但编译后,点BUTTON提示:DataBinder.Eval:“System.Data.DataRowView”不包含名称为 ProductTitle 的属性。
    因为我要把各种新闻的标题列出来,所以前台帮定的“ProductTitle”字段是不能换的。
    但还是要谢谢WangZWang(先来)
      

  2.   

    你的数据结构都不清楚,怎么帮你写SQL出来呀!
      

  3.   

    既然前台綁定的“ProductTitle”字段不能換??你為什麼要換為ProductContent ??
      

  4.   

    我想让
    string strSqlNewsContent = "select ProductID,ProductContent from (select ProductID,ProductTitle as ProductContent from ViewProducts union select ProductID,ProductTitle from ViewProductZ union select ProductID,ProductTitle from ViewProductH) a where ProductContent like '%"+SearchKey+"%'";
    按ProductContent来查询,但这个语句是按ProductTitle查询的。
      

  5.   

    第二个语句中的ProductContent在from从句中根本就不存在,出错是正常的,一楼的方法可以解决问题。