日期:2014-05-18  浏览次数:20828 次

C# ORA-00933:SQL命令为正确结束
代码:
 
C# code

       
        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是数据库的一个表名也是正确的,请各位大侠帮忙

------解决方案--------------------
sql最后多了一个反括号!
------解决方案--------------------
调试一下,把sql语句复制到sqlplus里执行一下呗
------解决方案--------------------
SQL中最后的右括号是?
------解决方案--------------------
sql最后的又括号不要