代码:
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"];
}
错误提示posconf不正确,但是sql语句是正确的posconf是数据库的一个表名也是正确的,请各位大侠帮忙
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"];
}
错误提示posconf不正确,但是sql语句是正确的posconf是数据库的一个表名也是正确的,请各位大侠帮忙
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货