日期:2014-05-18 浏览次数:20893 次
public DataSet GetDataSet(string sql, string tableName) { //创建数据适配器 OracleDataAdapter da = new OracleDataAdapter(sql, GetConn()); //创建数据集 DataSet ds = new DataSet(); //填充数据集 da.Fill(ds, tableName); return ds; } private void button1_Click(object sender, EventArgs e) { //查询时间段内所有路段信息 if (Convert.ToDateTime(this.dtEnd.Text) > Convert.ToDateTime(this.dtStart.Text)) { //if (!string.IsNullOrEmpty(this.section.Text)) //{ // Linkid = Convert.ToInt32(this.section.Text); //} StartTime = Convert.ToDateTime(this.dtStart.Text.Trim()); EndTime = Convert.ToDateTime(this.dtEnd.Text.Trim()); //查询时间段内所选路段黄色信息 if (this.section.Text != null && cobYello.CheckState == CheckState.Checked && cobred.CheckState == CheckState.Unchecked && radup.Checked == true && radown.Checked == false) { string sql = String.Format("select p.posdesc,p.updir,p.roadtype,to_char(t.rectime,'HH24:MI:SS') from posconf p ,traffinfo5 t where p.posdesc='{0}' and t.rectime>=to_date('{1}','yyyy-mm-dd HH24:mi:ss') and t.rectime<=to_date('{2}','yyyy-mm-dd HH24:mi:ss') and speed< 25 and speed >= 10 and t.posid=p.posid and t.laneno=100)", Posdesc, StartTime, EndTime); DataSet ds = GetDataSet(sql, "posconf"); dg.Refresh(); this.dg.DataSource = ds.Tables["posconf"]; }