public void FillRepeaterIsShow(Repeater repeater, string tableName, string rowName, string rowValue, int top, bool IsShow,string orderByName)
{
SqlStr = "SELECT top " + top.ToString() + " * from " + tableName.Trim() + " where " + rowName.Trim() + "= ' " + rowValue.Trim() + " ' and " + " IsShow= " + IsShow.ToString() + " order by " + orderByName;
ds = helper.ExecuteDataset(ConnStr, CommandType.Text, SqlStr);
repeater.DataSource = ds.Tables[0];
repeater.DataBind();
}
执行语句:mydb.FillRepeaterIsShow(YeJieXinWen, "News ", "N_Type ", "业界动态 ", 15, true, "N_Type ");
ChangJianWenTi:repeater名称
News: 要绑定的表明
N_Type:where N_Type
常见问题: N_Type的值
15:只显示15条
true:IsShow = true
N_Date:根据N_Date排序
错误提示:ORDER BY 子句语法错误。 去掉 + " order by " + orderByName就没错
------解决方案--------------------------------------------------------
呵呵,的确是,那接分吧。
------解决方案--------------------------------------------------------
SqlStr = "SELECT top " + top.ToString() + " * from " + tableName.Trim() + " where " + rowName.Trim() + "= ' " + rowValue.Trim() + " ' and " + " IsShow= " + IsShow.ToString() + " order by " + orderByName;
------解决方案--------------------------------------------------------
mydb.FillRepeaterIsShow(YeJieXinWen, "News ", "N_Type ", "业界动态 ", 15, true, "N_Type ");
N_Date:根据N_Date排序
最后的参数到底是 "N_Type "还是 "N_Date "?
再有,你将SQL语句输出到查询分析器里运行看看,就明白了
------解决方案--------------------------------------------------------
晕哦,这么多人都回复了...