vs2008的winform报表问题
在WinForm中建了一个报表CrystalReport1.rpt以及数据集DataSet,在窗体中绑定了数据,现在遇到的问题是在报表中只显示字段不显示数据(数据库表中有数据),捣鼓里一天也没整明白,我是第一次接触报表,希望大家给点意见,先谢过了!
就在窗体中写了代码,如下:
private void Form3_Load(object sender, EventArgs e)
{
string strPath = Application.StartupPath.Substring(0, Application.StartupPath.Substring(0, Application.StartupPath.LastIndexOf("\")).LastIndexOf("\"));
strPath += @"\CrystalReport1.rpt";
SqlConnection con = new SqlConnection("Data Source=CY-63FBE3FF6AE5\\SQLEXPRESS;database = lengku;user id =sa;pwd =sa;");
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from tb_HisTemp", con);
DataSet ds = new DataSet();
da.Fill(ds, "tb_HisTemp");
ReportDocument rd = new ReportDocument();
rd.Load(strPath);
rd.SetDataSource(ds.Tables[0].DefaultView);
this.crystalReportViewer1.ReportSource = strPath;
crystalReportViewer1.RefreshReport();
}