调试程序时出现了错误private void showDownload()
        {
            
            DataSet    ds    = Db.ExecuteToDataSet("SELECT p.name,t.title FROM teacher_work_info t,person_info p,student_work_info s WHERE s.teacherid=t.teacherid and t.teacherid=p.id and t.id="+Request.Params["id"]);
            TextId.Text=Request.Params["id"].ToString();
            DataRow    tempRow    = ds.Tables[0].Rows[0];//此处错误:在位置 0 处没有任何行。
            TextTeacher.Text=tempRow["name"].ToString();
            TextStudent.Text=Session["name"].ToString();
            TextTitleCon.Text=tempRow["title"].ToString();
            ds.Dispose();
            TextId.Enabled=false;
            TextTeacher.Enabled=false;
            TextStudent.Enabled=false;
            TextTitleCon.Enabled=false;
            DropDownListGrade.Enabled=false;        }
用查询分析器试了下,提示  'SELECT p.name,t.title FROM teacher_work_info t,person_info p,student_work_info s WHERE s.teacherid=t.teacherid and t.teacherid=p' 开头的 标识符 太长。最大长度为 128    的错误
网上查了下,不少都是说用单引号取代双引号,为什么我这么做了也不对?
关于ExecuteToDataSet的定义如下:public static DataSet ExecuteToDataSet(string sqlStr)
        {
            SqlDataAdapter da;
            DataSet            ds    = new DataSet();
            try
            {
                da                    = new SqlDataAdapter(sqlStr,conn);
                da.Fill(ds);
                da.Dispose();
                ds.Dispose();
                return ds;
            }
            catch(Exception e)
            {
                throw new Exception(e.Message);
            }
        }

解决方案 »

  1.   

    "SELECT p.name,t.title FROM teacher_work_info t,person_info p,student_work_info s WHERE s.teacherid=t.teacherid and t.teacherid=p.id and t.id="+Request.Params["id"]'SELECT p.name,t.title FROM teacher_work_info t,person_info p,student_work_info s WHERE s.teacherid=t.teacherid and t.teacherid=p'这两句不同啊 
      

  2.   

    还没改出来,只能继续顶了。help!
      

  3.   

    是否返回了一个无记录的表
    如果table[0]无记录,则row[0]肯定无数据在sql server中直接执行一下
    SELECT p.name,t.title FROM teacher_work_info t,person_info p,student_work_info s WHERE s.teacherid=t.teacherid and t.teacherid=p.id and t.id="+Request.Params["id"]);
    看看结果