public partial class controls_Bulletin : System.Web.UI.UserControl
{
private SqlCommand Command;
private SqlConnection Connection;
private SqlDataAdapter DataAdapter;
private DataTable NewsTable;
private XmlDocument XmlDoc;
//protected Panel NoPicturePan;
private void DataLoad()
{
this.EnableViewState = false;
if (this.Visible)
{
this.XmlDoc = new XmlDocument();
this.XmlDoc.Load(base.Request.PhysicalApplicationPath + "Config/AppConfig.config");
byte num1 = Convert.ToByte(this.XmlDoc.GetElementsByTagName("TopImgNum").Item(0).Attributes["value"].Value);
byte num2 = Convert.ToByte(this.XmlDoc.GetElementsByTagName("TopNewsNum").Item(0).Attributes["value"].Value);
{
this.NewsTable = new DataTable();
this.Connection = new SqlConnection(DataProvider.ConnectionString);
this.Command = new SqlCommand();
this.Command.Connection = this.Connection;
num2 = 9;
//this.Command.CommandText = "Select Top " + num2 + " Articleid,Classid,Title,AddTime,HighLight,IndexTop From Article Where ImgNews=false And (IndexTop=true Or HeadLine=true) Order By IndexTop,Articleid Desc";
this.Command.CommandText = "Select Top 1 Articleid,Classid,Title,AddTime,HighLight,Hits,IndexTop From Article where Classid in (select Classid from aClass where Classid=24 ) Order By sortid desc,addtime Desc";
this.DataAdapter = new SqlDataAdapter();
this.DataAdapter.SelectCommand = this.Command;
this.DataAdapter.Fill(this.NewsTable);
this.Command.Dispose();
this.DataAdapter.Dispose();
this.Connection.Dispose();
this.NewsTable.Columns.Add("ClassName", typeof(string));
for (int num3 = 0; num3 < this.NewsTable.Rows.Count; num3++)
{
for (int num4 = 0; num4 < NavigateTree.InfinityTree.Rows.Count; num4++)
{
if (Convert.ToInt32(this.NewsTable.Rows[num3]["Classid"]) == Convert.ToInt32(NavigateTree.InfinityTree.Rows[num4]["Classid"]))
{
this.NewsTable.Rows[num3]["ClassName"] = NavigateTree.InfinityTree.Rows[num4]["ClassName"];
}
}
}
base.Cache["Bulletin"] = this.NewsTable.Copy();
this.ArticleRpt.DataSource = this.NewsTable;
this.ArticleRpt.DataBind();
this.NewsTable.Dispose();
}
}
}
如何能在加粗代码处多添加一条数据连接Classid=4,有办法实现吗
------解决思路----------------------
(select Classid from aClass where Classid=24 or Classid=4 )
------解决思路----------------------
class in (4,24)
------解决思路----------------------
select top 2 * from Article where classid=4
UNION select top 2 * from Article where classid=24
------解决思路----------------------
有两个思路
一个是原先的两个公告里各3条(具体几条根据你要展示的条目计算),那么参考12楼可解决
还一个思路是,你要取4,24两个里面的新闻按照时间排序靠前的