using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;


namespace WindowsApplication1
{
    public partial class Form3 : Form
    {
        Buessiness business = new Buessiness();
        Mydatabase db = new Mydatabase();
        public Form3()
        {
            InitializeComponent();
            //1、如何获取水晶报表的rpt文件
            string path = Environment.CurrentDirectory + "\\CrystalReport1.rpt";
            //MessageBox.Show(path);
            ReportDocument report = new ReportDocument();
            report.Load(path);//加载报表

            //下面开始动态加载SQL脚本，此次是通过dataset加载水晶报表
            DataSet Ds = db.GetDataSet("select student.sno,student.sname,student.snumber,everystuavg.stuavg from  student,everystuavg where student.sno=everystuavg.sno and student.bno=31");
            report.SetDataSource(Ds.Tables[0]);

            //最后绑定数据源，不写无法显示哦^o^
            this.crystalReportViewer1.ReportSource = report;

        }

    }
}