时间:2021-07-01 10:21:17 帮助过:15人阅读
ListViewItem listViewItem=new ListViewItem(); listViewItem.SubItems[0].Text=""11111;//第一行第一例的值 listViewItem.SubItems.Add("222");/// listViewItem.SubItems.Add("222");///以此类推 ListView1.Items.Add(listViewItem);
三、Access中时间段查询的SQL语句书写规范(采用dateTimePick控件)
注意:# 是必须要加的
string sql=select * from tableName where timeField between #"+dateTimePick1.value.ToString()+"# and #"+dateTimePick2.vlaue.ToString()+"#";
四、连接数据库,按条件查询数据并显示在ListView中
string path = System.Environment.CurrentDirectory + "\\database.mdb"; OleDbConnection con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path);//station2.mdb con.Open(); string sql = "select * from SendRecord where SENDTIME between #" + dateTimePicker1.Value.ToString() + "# and #" + dateTimePicker2.Value.ToString() + "#"; // string sql = "select * from SendRecord"; OleDbDataAdapter da = new OleDbDataAdapter(sql, con); DataSet dt = new DataSet(); da.Fill(dt); DataTable dtb = dt.Tables[0]; foreach (DataRow row in dtb.Rows) { ListViewItem listviewItem = new ListViewItem(); listviewItem.SubItems.Clear(); listviewItem.SubItems[0].Text = string.Format("{0:yyyy-MM-dd HH:mm}", row["SENDTIME"]); listviewItem.SubItems.Add((string)row["SENDER"]); listviewItem.SubItems.Add((string)row["CONTENT"]); listviewItem.SubItems.Add(string.Format("{0}", row["AUDITOR"])); listviewItem.SubItems.Add(string.Format("{0:yyyy-MM-dd HH:mm}", row["AUDITTIME"])); listviewItem.SubItems.Add(string.Format("{0}", row["AUDITSTATUS"])); listView1.Items.Add(listviewItem); } con.Close(); }
C# 将Access中时间段条件查询的数据添加到ListView中
标签:dap 时间 datetime tab log ati data time http