4,816
社区成员
发帖
与我相关
我的任务
分享
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();
}