form1.cs
来自「c#实现对水晶报表的开发和调用实例。对初学者有着很好的帮助。」· CS 代码 · 共 39 行
CS
39 行
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 + =
减小字号Ctrl + -
显示快捷键?