0
我正在使用列表視圖來顯示訪問數據庫數據。如何在日程表中按降序顯示訪問數據庫數據
我是一個稱爲Date.there柱分別超過360天的數據與數據
例日期,date format = yyyyMMdd.
它顯示升序
20111104
20111105
20111106
20111107
20111108
我想顯示按日期的數據降序排列如下
20111108
20111107
20111106
20111105
20111104
我正在使用這些代碼在列表視圖中顯示acces數據。
try
{
con.Open();
DataTable dt = new DataTable();
DataSet ds = new DataSet();
ds.Tables.Add(dt);
OleDbDataAdapter da = new OleDbDataAdapter("select * from MyTable", con);
da.Fill(dt);
int iRecords = 0;
foreach (DataRow myrow in dt.Rows)
{
ListViewItem lItem = new ListViewItem();
lItem.UseItemStyleForSubItems = false;
lItem = listviewTargets.Items.Insert(iRecords, Date.ToString());
//Note in the above line "Date.ToString" is written
lItem.UseItemStyleForSubItems = false;
// listviewTargets.Items.Add(myrow[2].ToString());
lItem.SubItems.Add(myrow[0].ToString());
lItem.SubItems.Add(myrow[3].ToString());
lItem.SubItems.Add(myrow[14].ToString());
lItem.SubItems.Add(myrow[4].ToString(), Color.White, Color.Green, lItem.Font);
lItem.SubItems.Add(myrow[6].ToString());
lItem.SubItems.Add(myrow[7].ToString());
lItem.SubItems.Add(myrow[8].ToString());
lItem.SubItems.Add(myrow[9].ToString());
iRecords++;
lItem = listviewTargets.Items.Insert(iRecords, "");
lItem.UseItemStyleForSubItems = false;
//iRecords = iRecords - 1;
// lItem.SubItems.Add("");
lItem.SubItems.Add("");
lItem.SubItems.Add("");
lItem.SubItems.Add("");
lItem.SubItems.Add(myrow[5].ToString(), Color.White, Color.Red, lItem.Font);
lItem.SubItems.Add(myrow[10].ToString());
lItem.SubItems.Add(myrow[11].ToString());
lItem.SubItems.Add(myrow[12].ToString());
lItem.SubItems.Add(myrow[13].ToString());
iRecords++;
}
// gv_ViewAllEntries.DataSource = ds.Tables["MyTable"];
con.Close();
}
catch (Exception)
{
con.Close();
}
在此先感謝
1分鐘,請我會 –
感謝檢查它的工作我想使用OleDbDataAdapter的DA =新OleDbDataAdapter的( 「SELECT * FROM realtimedata其中(名稱='」 +姓名+「')」,con);與命令,因爲有很多名字也 –
然後,再次看看[ORDER BY](http://msdn.microsoft.com/en-us/library/ms188385.aspx)並自己應用它。 – CodeCaster