Problem in calling crystal report using selection formula with dates

madhugp

Member
Joined
Nov 27, 2017
Messages
20
Programming Experience
5-10
Hi

I am trying to call crystal report from c# using a button click.
In the form I have two datetimepicker controls named DT1 , DT2.

I have used the following code in button.

crpt is the crystal report conrtrol. pur_ord_vw is the view in database.


UserId = "sa";
Password = "gms123";
crpt.Connect = "UID=" + UserId + ";PWD=" + Password;
crpt.WindowState = Crystal.WindowStateConstants.crptMaximized;
crpt.Destination = Crystal.DestinationConstants.crptToWindow;


crpt.SelectionFormula = "{pur_ord_vw.inward_dt} >= '"DT1.Text.ToString()+"'
and {pur_ord_vw.inward_dt} <= '"DT1.Text.ToString()+"'";

there is no error and no response from crystal report.

If remove the selection formula then report is opening with entire data of view.

plz suggest me how to pass the selection formula with dates.

thanks and regards

Gms

What I have tried is the below, but no use.

crpt.SelectionFormula = "{pur_ord_vw.inward_dt between Convert.ToDateTime(DT1.Text) and Convert.ToDateTime(DT2.Text)}";

crpt.SelectionFormula = "{pur_ord_vw.inward_dt} >= '"+ Convert.ToDateTime(DT1.Text)+"' and {pur_ord_vw.inward_dt} <= '"+ Convert.ToDateTime(DT1.Text)+"'";

 

Latest posts

Back
Top Bottom