⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.cs

📁 c#实现对水晶报表的开发和调用实例。对初学者有着很好的帮助。
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        private static string dbPath = Application.StartupPath + @"\BatchProcessStudentWork.mdb";
       
        public Form1()
        {
            InitializeComponent();
        }

        private void reportDocument1_InitReport(object sender, EventArgs e)
        {
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            System.Data.OleDb.OleDbConnection oleCon = new System.Data.OleDb.OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dbPath);
            string sqlStr = "SELECT * FROM CourseInfo";
            OleDbCommand cmd = new OleDbCommand(sqlStr, oleCon);
            OleDbDataAdapter odap = new OleDbDataAdapter(cmd);
            DataSet ds = new DataSet();
            odap.Fill(ds, "CourseInfo");

            this.reportDocument1.FileName = Application.StartupPath + @"\cryRpt.rpt";
            this.reportDocument1.SetDataSource(ds);
            this.crystalReportViewer2.ReportSource = this.reportDocument1;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -