报表为什么没显示数据???
{
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显示我想要的数据/....
------解决方案--------------------
oC.LocalReport.ReportPath = "Report1.rdlc ";
改成完整路径试试:
oC.LocalReport.ReportPath = Application.StartPath+ "\Report1.rdlc ";