即将在vb.net中显示水晶报告 [英] about to display crystal report in vb.net
本文介绍了即将在vb.net中显示水晶报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用参数值在另一个表单上单击打印按钮后编写显示水晶报告的代码?(例如,要从账单号打印客户账单 - 处理 - 选择账单号 - >点击打印按钮 - >显示给定账单的特定账单号。)我可以写什么代码来正确显示这个账单?
how to write code to display crystal report after clicking print button on another form using parameter value?(ex. want to print a customer bill from bill no. Process- select bill no->click on print button->show the particular bill of given bill no.) what code can I write to display this bill properly?
推荐答案
你可以尝试这样的c#按钮代码但是我不要以为c#和vb代码之间会有这么大的区别。
//首先添加命名空间
u can try like that this is c# button code but i do not think there would be so much difference between c# and vb code .
// firstly add namespace
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Shared;
protected void btnPrint_Click(object sender, EventArgs e)
{
ReportDocument rptDoc = new ReportDocument();
rptDoc.Load(Server.MapPath("../RPT/crstSubReport.rpt"));
CrystalDecisions.Shared.TableLogOnInfo loginfo;
foreach (CrystalDecisions.CrystalReports.Engine.Table myTable in rptDoc.Database.Tables)
{
loginfo = myTable.LogOnInfo;
loginfo.ConnectionInfo.ServerName = @"";
loginfo.ConnectionInfo.DatabaseName = "";
loginfo.ConnectionInfo.UserID = "";
loginfo.ConnectionInfo.Password = "";
myTable.ApplyLogOnInfo(loginfo);
}
MemoryStream stream = (MemoryStream)rptDoc.ExportToStream(ExportFormatType.PortableDocFormat);
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/pdf";
Response.BinaryWrite(stream.ToArray());
rptDoc.Refresh();
}
这篇关于即将在vb.net中显示水晶报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文