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();

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

Sorry this code also not working

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.