Ms rdlc 打印
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Common;
using System.Data.Common;
namespace Client
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
private void Form3_Load(object sender, EventArgs e)
{
this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("RailwayDataDataSet_BridgeList", ReturnData()));
this.reportViewer1.LocalReport .ReportPath=@"D:\铁路\Client\Client\Report1.rdlc";
this.reportViewer1.RefreshReport();
this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
}
public DataTable ReturnData()
{
string sql = "select * from BridgeList";
Database db = DatabaseFactory.CreateDatabase();
DbCommand dc = db.GetSqlStringCommand(sql);
return db.ExecuteDataSet(dc).Tables[0];
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Common;
using System.Data.Common;
namespace Client
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
private void Form3_Load(object sender, EventArgs e)
{
this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("RailwayDataDataSet_BridgeList", ReturnData()));
this.reportViewer1.LocalReport .ReportPath=@"D:\铁路\Client\Client\Report1.rdlc";
this.reportViewer1.RefreshReport();
this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
}
public DataTable ReturnData()
{
string sql = "select * from BridgeList";
Database db = DatabaseFactory.CreateDatabase();
DbCommand dc = db.GetSqlStringCommand(sql);
return db.ExecuteDataSet(dc).Tables[0];
}
}
}