public void DataGridDataBind()
{
OleDbConnection ObjConn=new OleDbConnection(@DataBaseDB.ConnectionString);
OleDbDataAdapter OjbCommand1=new OleDbDataAdapter("SELECT top 5 * FROM News order by AddDT desc",ObjConn);
DataSet ds1=new DataSet();
OjbCommand1.Fill(ds1);
this.myDataGrid.DataSource=ds1;
this.myDataGrid.DataBind();
ObjConn.Close();
}
上面的运行时还正常的,当我在查询语句中加入条件改成如下:SELECT top 5 * FROM News where MenuId=2 order by AddDT desc时就不正确了,显示的就不只五条记录了.不知道为什么?请高手指点.
{
OleDbConnection ObjConn=new OleDbConnection(@DataBaseDB.ConnectionString);
OleDbDataAdapter OjbCommand1=new OleDbDataAdapter("SELECT top 5 * FROM News order by AddDT desc",ObjConn);
DataSet ds1=new DataSet();
OjbCommand1.Fill(ds1);
this.myDataGrid.DataSource=ds1;
this.myDataGrid.DataBind();
ObjConn.Close();
}
上面的运行时还正常的,当我在查询语句中加入条件改成如下:SELECT top 5 * FROM News where MenuId=2 order by AddDT desc时就不正确了,显示的就不只五条记录了.不知道为什么?请高手指点.
select top 5 * from studentInfor where sname='liujia' order by sno desc输出如下:03281310 liujia
03281309 liujia
03281308 liujia
03281305 liujia