Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to: Speed up Crystal Reports when using ADO
Message
De
14/01/2004 12:05:14
 
 
À
13/01/2004 22:57:33
Information générale
Forum:
Visual FoxPro
Catégorie:
Crystal Reports
Divers
Thread ID:
00866585
Message ID:
00866801
Vues:
17
The static cursor certainly makes sense because ADO doesn't have to worry about updateable data. The client side cursor may actually be different in different scenarios. For example, if the workstation is low on memory it may be slower.


>I discovered this and wanted to share it for what its worth. I have a VFP8 app that does a lot of reporting out of SQL Server 2000. The reporting is done in Crystal Reports 8.5 through integration with the CRViewer object placed on a VFP form. The data is retrieved from SQL2K stored procedures using ADO.
>
>What I found was that, by setting the ADO RecordSet - CursorLocation to 3 (adUseClient), and the CursorType to 3 (adOpenStatic), the time it takes to retrieve the data and render the report in Crystal is one third of the time if I did not set these settings. Also, by setting the CursorType to Static, it allows you to access the RecordSet's RecordCount property, which you may want to use. I'm not sure why this makes such a big improvement, but I think it must be that having the data local to the client allows Crystal to render the report instantly, once it has the data. Otherwise, Crystal would show a blank page for a while, before it actually rendered any data on the report.
>
>Below is some code I pulled out of my class, in case anyone is interested.
>
>-------------
>
>* Note: We create a client-side, static ado recordset because it's faster than server-side, forward-only RS.
>
>oAdoConn = CreateObject('AdoDb.Connection')
>oAdoConn.ConnectionString= m.tcConnString
>oAdoConn.Open
>
>oAdoRS= CREATEOBJECT("adodb.RecordSet")
>WITH oAdoRS
> .ActiveConnection= oAdoConn
> .source= m.tcExecute && Can be a SELECT statement or Table name.
> .cursorLocation= 3 && adUseClient - cursor must be client side to be Static
> .CursorType= 3 && adOpenStatic - Static allows us to get RecordCount
> .open()
>ENDWITH
>
>this.nRecordsRetrieved= oAdoRS.RecordCount && set recs retrieved to display to user
>
>IF not oAdoRS.EOF
> oCrystal= Createobject("CrystalRuntime.Application")
> oReport= oCrystal.OpenReport(goapp.xcReportPath + thisform.xcRptCode + ".RPT")
>
> * Assign the formula values.
> thisform.xAssignFormulas(oReport)
>
> * Pass the recordset to the report.
> thisform.xBindRecordSetToReport(oReport, oAdoRS, "aa")
>
> * Turn on dual interface support. Must do this before the form with the ole control gets instantiated
> =Sys(2333, 1)
>
> DO FORM CrPreview WITH oReport
>ENDIF
>-------------
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform