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.RecordSelectionFormula = "{cashtbl.stdid}=7";---working fine


//the below code gives error saying number is equired         
rpt.RecordSelectionFormula = "{cashtbl.stdid}='" +Convert.ToInt32(textBox2.Text) + "'";
            crystalReportViewer1.ReportSource = rpt;

Edited 3 Years Ago by pyTony: fixed formating

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 :)


please check this code , it is in 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)


        End With


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.

This article has been dead for over six months. Start a new discussion instead.