Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Unable to change sql statement on the fly in Crystal
Message
From
14/07/2005 10:03:17
 
 
To
14/07/2005 03:45:02
General information
Forum:
Visual FoxPro
Category:
Crystal Reports
Miscellaneous
Thread ID:
01032526
Message ID:
01032618
Views:
29
Change the filter part of the query to use a parameter, then pass that parameter to Crystal from you VFP app.

>Hi All,
>I have made report in crystal with ADO. The report is based on one tables orders from norwind fox database. The report from inside crystal is running fine. It can also run from inside fox using RDC.
>The problem is that I am unable to change the SQL query that the report is based from inside VFP to for instance filter the data. I use the following code to change the query (the main part of the code is from a technical article of Mr. Craig Berntson) :
>
>
>
>
>loConn = CREATEOBJECT("ADODB.Connection")
>loConn.ConnectionString = "Provider=VFPOLEDB.1;Data Source=c:\program files\microsoft visual foxpro 9\samples\northwind\northwind.dbc;Password=''"
>
>loConn.Open()
>loRS = CREATEOBJECT("ADODB.RecordSet")
>loRS.Open("Select * FROM orders where customerid='VINET'", loConn)
>
>loCR = CREATEOBJECT("CrystalRuntime.Application")
>
>loRpt = loCR.OpenReport("C:\testcrystalado\vfpoledb.rpt")
>loDB = oRpt.Database()
>locDBT = oDB.Tables()
>locdbt.Add("orders",)
>loDBT = locDBT.Item(1)
>loDBT.SetDataSource(loRS)
>
>
>IF loRPt.HasSavedData
>   loRPT.DiscardSavedData()
>ENDIF
>
>
>loRpt.PrintOut()
>
>
>
>
>Even though I change the query the report still returns the data of the original sql statement saved in the report.
>
>Thanks
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform