2006年11月26日
.cs代码:
protected void bt_push_Click(object sender, EventArgs e)
{
string sql = "select * from student where student_name = '009'";
string DBConfig_sql = @"Data Source=A3161228A954417;Initial Catalog=SMS;Persist Security Info=True;User ID=sa;Password=sa";
DataSet ds = new DataSet();
SqlConnection sqlCon = new SqlConnection(DBConfig_sql);
SqlCommand sqlCmd = new SqlCommand(sql, sqlCon);
SqlDataAdapter sqlAd = new SqlDataAdapter();
sqlAd.SelectCommand = sqlCmd;
sqlAd.Fill(ds, "student");
CrystalReportSource1.ReportDocument.Load(Server.MapPath("Report/CrystalReportpush.rpt"));
//注意此处必需指明Dataset中的表的名称,否则会提示“您请求的报表需要更多信息.”
CrystalReportSource1.ReportDocument.SetDataSource(ds.Tables["student"]);
CrystalReportSource1.DataBind();
CrystalReportViewer1.ReportSource = CrystalReportSource1;
CrystalReportViewer1.DataBind();
// this.Response.Write("<script>alert('rrrrrrrrrrrrr')</script>");

}.aspx代码:
<asp:Button id ="bt_push" runat ="server" Text ="Push打印调用模式" OnClick="push_Click"/>
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" />
<CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
</CR:CrystalReportSource>.rpt设置:
1、新建一个rpt
2、配置rpt文件

浙公网安备 33010602011771号