{
              DataSet ds = new DataSet();
            SqlConnection myconn = new SqlConnection("server=.;uid=sa;pwd=123;database=Pubs");
             myconn.Open();
            string strSql = "select * from jobs";
            SqlCommand cmd = new SqlCommand(strSql, myconn);
             SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.SelectCommand = cmd;
             da.Fill(ds, "jobs"); //填充数据集
             ReportViewer oC = new ReportViewer();
             oC.LocalReport.ReportPath = "Report1.rdlc";
             oC.LocalReport.DataSources.Add(new ReportDataSource("Report1", ds.Tables["jobs"]));
             oC.Dock = DockStyle.Fill;
             this.Controls.Add(oC);
             oC.RefreshReport();
           }我运行后也没报错?
但是在页面上显示为:
"本地报表处理期间出错,未指定报表"D:\My Documents\Visual Studio 2005\Projects\WindowsApplication3\WindowsApplication3\Report1.rdlc"的报表定
义"
"未能找到文件"D:\My Documents\Visual Studio 2005\Projects\WindowsApplication3\WindowsApplication3\Report1.rdlc"".我就是在项目下建立一个form1.cs然后在添加--->新建项--->Report1.rdlc
代码全在上面...
在Report1.rdlc的界面上我用添加数据源到 Pubs..然后到jobs 表..在把表中四个字段名拖到Report1.rdlc上....请问为什么不会在Report1.rdlc显示我想要的数据/....

解决方案 »

  1.   

    oC.LocalReport.ReportPath = "Report1.rdlc";
    改成完整路径试试:
     oC.LocalReport.ReportPath = Application.StartPath+"\Report1.rdlc";
      

  2.   

    还是不行哦/.///现在报错为"未为数据源"pubsDataSet_jobs"提供数据源实列";
    为什么呢?
      

  3.   

    添加:
    protected   CrystalDecisions.CrystalReports.Engine.ReportDocument   reportDocument1;   改成:
      reportDocument1.Load("d:\\Report2.rpt");   
      reportDocument1.SetDataSource(ds);   
      this.CrystalReportViewer1.ReportSource   =   reportDocument1;   
      CrystalReportViewer1.DataBind(); 
      

  4.   

    我在vs2005中reportViewer1没有ReportSource..谢谢楼上的兄弟..