Parameter to Crystal Report - crystal-reports

i created a #Month as parameter name in crystal report and just insert to the report header section.
When i run the report always it asks the parameter by showing one box. How i pass through code. My existing code is below
MyReport rpt = new MyReport();
var srcData = ; //here i added my LINQ statement to select the data
rpt.SetDataSource(srcData);
ParameterDiscreteValue pdValue = new ParameterDiscreteValue();
pdValue.Value = combo2.SelectedValue;
rpt.ParameterFields["#Month"].CurrentValues.Add(pdValue);
this.ReportViewer1.ReportSource = rpt;
this.ReportViewer1.RefreshReport();
Where i did the mistake?

Hi I solved by just removing RefershReport() method of crystalreportviewer
I find from : http://www.it-sideways.com/2011/10/how-to-disable-parameter-prompt-for.html

If it's not working it suggests a typo or something. Try analyzing rpt.ParameterFields (set a breakpoint and watch). Have you got the parameter name correct? Data type?

I had trouble with adding parameters as well. Here's an example of what I got working:
string ponumber = Request.QueryString["ponumber"].ToString();
string receiptno = Request.QueryString["receiptno"].ToString();
// Put Away Report
CrystalReportSource CrystalReportSource1 = new CrystalReportSource();
CrystalReportViewer CrystalReportViewer1 = new CrystalReportViewer();
CrystalReportViewer1.ReportSource = CrystalReportSource1;
CrystalReportViewer1.EnableParameterPrompt = false;
CrystalReportSource1.Report.FileName = "Report3.rpt";
CrystalReportSource1.EnableCaching = false;
// This will set the values of my two parameters in the report
CrystalReportSource1.ReportDocument.SetParameterValue(0, ponumber);
CrystalReportSource1.ReportDocument.SetParameterValue(1, receiptno);
TableLogOnInfo logOnInfo = new TableLogOnInfo();
logOnInfo.ConnectionInfo.ServerName = ConfigurationManager.AppSettings["WarehouseReportServerName"];
logOnInfo.ConnectionInfo.DatabaseName = ConfigurationManager.AppSettings["WarehouseReportDatabaseName"];
logOnInfo.ConnectionInfo.UserID = ConfigurationManager.AppSettings["WarehouseReportUserID"];
logOnInfo.ConnectionInfo.Password = ConfigurationManager.AppSettings["WarehouseReportPassword"];
TableLogOnInfos infos = new TableLogOnInfos();
infos.Add(logOnInfo);
CrystalReportViewer1.LogOnInfo = infos;
maindiv.Controls.Add(CrystalReportSource1);
maindiv.Controls.Add(CrystalReportViewer1);
CrystalReportViewer1.DataBind();

Related

Crystal Reports - how to pass parameter?

I would like to pass a parameter to my report and put the report into my project.
I want to pass a user id as parameter to the report.
The id will be different each time.
Can someone help me on this topic how to pass the parameter.
Here is my code so far:
CrystalReportViewer1.Visible = True
Dim rDoc As New ReportDocument()
' Crystal Report Name
rDoc.Load(Server.MapPath("Sucess.rpt"))
' Your .rpt file path
'set dataset to the report viewer.
CrystalReportViewer1.ReportSource = rDoc
You can try something like this:
string ponumber;
string receiptno;
ponumber = TextBox1.Text;
CrystalReportSource CrystalReportSource1 = new CrystalReportSource();
CrystalReportViewer CrystalReportViewer1 = new CrystalReportViewer();
CrystalReportViewer1.ReportSource = CrystalReportSource1;
CrystalReportViewer1.EnableParameterPrompt = false;
CrystalReportSource1.Report.FileName = "Report3.rpt";
CrystalReportSource1.EnableCaching = false;
CrystalReportSource1.ReportDocument.SetParameterValue(0, ponumber);
CrystalReportSource1.ReportDocument.SetParameterValue(1, receiptno);

Trying to insert QBO invoice with IPP.NET

I am attempting to insert an invoice into Quickbooks Online using IPP.NET. The problem seems to be in setting the item.
Here is a snippet of my VB code for the first line, which works fine...
Dim qboInvoiceLine1 as new intuit.ipp.data.qbo.invoiceline
qboInvoiceline1.desc="Desc1"
qboInvoiceLine1.amount=10
qboInvoiceLine1.AmountSpecified=True
If I add the following code for setting the item, I get an error forming the XML...
Dim items1 as List(Of Intuit.Ipp.Data.Qbo.Item)=New List(Of Intuit.Ipp.Data.Qbo.Item)
Dim item1 as new intuit.ipp.data.qbo.item
item1.id=new intuit.ipp.data.qbo.idtype
item1.id.value="1"
items1.add(item1)
qboInvoiceLine1.Items=items1.ToArray
I do not even understand why the item ID seems to be some kind of array or list of items. One source of documentation suggests there is an itemID property of the invoice line, but this does not seem to be the case. Can anyone give me code for setting the itemID for an invoice line?
ItemsChoiceType2[] invoiceItemAttributes = { ItemsChoiceType2.ItemId, ItemsChoiceType2.UnitPrice,ItemsChoiceType2.Qty };
object[] invoiceItemValues = { new IdType() { idDomain = idDomainEnum.QB, Value = "5" }, new decimal(33), new decimal(2) };
var invoiceLine = new InvoiceLine();
invoiceLine.Amount = 66;
invoiceLine.AmountSpecified = true;
invoiceLine.Desc = "test " + DateTime.Now.ToShortDateString();
invoiceLine.ItemsElementName = invoiceItemAttributes;
invoiceLine.Items = invoiceItemValues;
invoiceLine.ServiceDate = DateTime.Now;
invoiceLine.ServiceDateSpecified = true;
listLine.Add(invoiceLine);

Print the date range on the report

I have a date range for a report from a selector. How can I print that range on the report header? I am inside a Crystal Report - not from code. I have a select expert using a IsBetween on a date field. The form prints everything fine. I just want to display the date range. I have tried the OnFirstRecord and OnLastRecord and WhilePrintingRecord to populate a string within a function - it just shows up as blank in the report.
// {#range}
// note case of format string
ToText(Minimum({?date_range}),"MM/dd/yyyy") + " - " + ToText(Maximum({?date_range}),"MM/dd/yyyy")
Add one or two Parameter in crystal report as per your requirement and then assign your date range to that parameters.
ParameterFields paramFields = new ParameterFields();
// ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
ParameterField paramField = new ParameterField();
ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
paramField.Name = "#Date1";
paramDiscreteValue.Value = TextBox1.Text.ToString();
paramField.CurrentValues.Add(paramDiscreteValue);
paramFields.Add(paramField);
paramField = new ParameterField(); // <-- This line is added
paramDiscreteValue = new ParameterDiscreteValue(); // <-- This line is added
paramField.Name = "#Date2";
paramDiscreteValue.Value = TextBox2.Text.ToString();
paramField.CurrentValues.Add(paramDiscreteValue);
paramFields.Add(paramField);
CrystalReportViewer1.ParameterFieldInfo = paramFields;
I found the NthSmallest and NthLargest functions - works perfectly now!

How to textbox value as a parameter in crystal report?

How to pass textbox values as parameter in crystal report in asp.net C#?
I want example which shows steps to passparamter
I have tried many examples but no output..
I want as in below link
http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-string-parameter.htm
But no data is displaying
Pls help
try this code
ReportDocument reportDocument = new ReportDocument();
ParameterFields paramFields = new ParameterFields();
ParameterField paramField = new ParameterField();
ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
paramField.Name = "#CustomerName";
paramDiscreteValue.Value = TextBox1.Text.ToString();
paramField.CurrentValues.Add(paramDiscreteValue);
paramFields.Add(paramField);
CrystalReportViewer1.ParameterFieldInfo = paramFields;
reportDocument.Load(Server.MapPath("CrystalReport.rpt"));
CrystalReportViewer1.ReportSource = reportDocument;
I hope this will help:
ReportDocument cryReportDocument = .......;
cryReportDocument.SetDatabaseLogon("userName", "password");
cryReportDocument.SetParameterValue("parameterName", yourTextBoxName.Text);
CrystalReportViewer1.ReportSource = cryReportDocument;

Despite loading new data from code, report displays original data

as below i have code to display data,
it works very fine, while data available..
but it shows same data, if query doeent return any rows, it shows last loaded data,
even if query returns other data eventhough it shows last loaded data..
please help me out...
ReportDocument rptdoc = new ReportDocument();
Ds2 = new DataSet();
Ds2 = ClsPos.GetRejectedByPosition(int.Parse(Request.QueryString.Get("ID")));
string ReportName = Server.MapPath("RejectedCandidate.rpt");
rptdoc.Load(ReportName);
// Position Name
ParameterFields Parameters = new ParameterFields();
ParameterField idget = new ParameterField();
idget.Name = "PositionName";
ParameterDiscreteValue values = new ParameterDiscreteValue();
values.Value = Request.QueryString.Get("PositionName");
idget.CurrentValues.Add(values);
Parameters.Add(idget);
CRViewer1.ParameterFieldInfo = Parameters;
rptdoc.SetDataSource(Ds2.Tables["GetValues"]);
CRViewer1.ReportSource = ReportName;
CRViewer1.DisplayGroupTree = false;
use rptDoc.Refresh(); after loading report. i.e.
rptdoc.Load(ReportName);
rptDoc.Refresh();