954,529 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Recordselectionformula in crystalreport giving error

In My windows application selection formula having textbox value gives error.
Not recognising expression without textbox it is working fine.
CrystalDecisions.CrystalReports.Engine.ReportDocument rpt;
rpt = new CrystalReport6();
rpt.Load(@"H:\CrystalReportsApplication1\CrystalReportsApplication1\CrystalReport6.rpt");
// rpt.RecordSelectionFormula = "{cashtbl.stdid}=7";---working fine
or
//the below code gives error saying number is equired
rpt.RecordSelectionFormula = "{cashtbl.stdid}='" +Convert.ToInt32(textBox2.Text) + "'";
crystalReportViewer1.ReportSource = rpt;
crystalReportViewer1.Refresh();

srm2010
Newbie Poster
21 posts since Dec 2010
Reputation Points: 9
Solved Threads: 0
 

hello !

rpt.RecordSelectionFormula = "{cashtbl.stdid}='" +Convert.ToInt32(textBox2.Text) + "'";

in above line you are converting textbox value in to integer and after that you are using '' and dealing like a string .use this

rpt.RecordSelectionFormula = "{cashtbl.stdid}= +Convert.ToInt32(textBox2.Text);


Hope this will solve your prob,if yes please mark your thread solved :)

Regards

waqasaslammmeo
Posting Pro in Training
472 posts since Aug 2011
Reputation Points: 38
Solved Threads: 82
 

Sorry this code also not working

srm2010
Newbie Poster
21 posts since Dec 2010
Reputation Points: 9
Solved Threads: 0
 

hello!
please check this code , it is in vb.net but may be this will give you any idea :)

Sub Purchase_VenderWise()
        With Frm_ListOfPurchaseHistory

            .rpt_PurchaseHistory1.DataSourceConnections(0).SetConnection(myCrServerName, myCrDatabaseName, myCRUserName, myCRUserPassword)
           .CrystalReportViewer1.SelectionFormula = "{PurchaseHead.VenderID}=" & Val(Me.txtinput.Text)
           
            .CrystalReportViewer1.SelectionFormula = "{PurchaseHead.PurchaseDate} in DateTime(" & Me.dtpfrom.Value.Year & "," & Me.dtpfrom.Value.Month & "," & Me.dtpfrom.Value.Day & ") to DateTime(" & Me.dtpto.Value.Year & "," & Me.dtpto.Value.Month & "," & Me.dtpto.Value.Day & ")" & " and {PurchaseHead.VenderID}=" & Val(Me.txtinput.Text)

            .Show()

        End With


Regards

waqasaslammmeo
Posting Pro in Training
472 posts since Aug 2011
Reputation Points: 38
Solved Threads: 82
 

Yes I could get the date working using datepicker.value but I can see both date and time coming in crystalreportviewer.I tried settings in crystalreportviewer but does not work.
Thanks for your help in advance.

srm2010
Newbie Poster
21 posts since Dec 2010
Reputation Points: 9
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You