从vb.net Windows应用程序传递日期范围参数 [英] passing date range parameters from a vb.net windows application
问题描述
我需要将日期范围参数传递到来自vb.net应用程序的水晶报表,但我不知道如何。对于任何人谁可能想帮助我,请自己基于以下场景:
I need to pass date range parameters to a crystal report from a vb.net application, but I don't know how to. For anyone who may want to help me, please base yourself on the following scenario:
我有一个水晶报告从oracle数据库中提取数据。在数据库中,我有一张学生表,每个记录都有出生日期,姓名和姓氏。我需要在报告上仅显示出生日期在日期X和日期Y之间(包括两者)的记录。日期X和日期Y是打开报告时在vb.net应用程序上传递的日期。
我使用水晶报表9,visual studio 2008和oracle 9i。
I have a crystal report that pulls data from an oracle database. In the database, I have a table of students, and each record has a birth date, name and surname. I need to display on the report only records where the birth date is between date X and date Y inclusive of both. Date X and Date Y are dates passed on the vb.net application when opening the report. I am using crystal reports 9, visual studio 2008 and oracle 9i.
有人请帮我,怎么实现?
Somebody please help me out, how do I achieve this?
推荐答案
string rang1 = Session["Rang1"].ToString();
string rang2 = Session["Rang2"].ToString(); ;
ReportDocument obj = new ReportDocument();
obj.Load(Server.MapPath("~/CType_CrystalReport.rpt"));
obj.SetDatabaseLogon("sa", "12qwaszx", "BTS-10", "BTS_ERP");
ParameterFields paraf = new ParameterFields();
ParameterField par = new ParameterField();
ParameterField par2 = new ParameterField();
par.ParameterFieldName = "CtCode";
ParameterDiscreteValue dcpara1 = new ParameterDiscreteValue();
ParameterDiscreteValue dcpara2 = new ParameterDiscreteValue();
par.Name = rang1;
par2.Name = rang2;
dcpara1.Value = rang1.ToString();
par.CurrentValues.Add(dcpara1);
paraf.Add(par);
dcpara2.Value = rang2.ToString();
par2.CurrentValues.Add(dcpara2);
paraf.Add(par2);
CrystalReportViewer1.ParameterFieldInfo = paraf;
obj.SetParameterValue("CtCode", dcpara1);
obj.SetParameterValue("CtCode", dcpara2);
CType_DataSet dsCustomers = GetData("select * from GL_CUSTTYPE where CT_CODE between '" + rang1.ToString() + "' AND '" + rang2.ToString() + "' ");
obj.SetDataSource(dsCustomers);
CrystalReportViewer1.ReportSource = obj;
CrystalReportViewer1.RefreshReport();
这篇关于从vb.net Windows应用程序传递日期范围参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!