Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Pass ADO Recordset From Fox to a Crystal Report
Message
De
12/07/2002 01:33:53
Nancy Folsom
Pixel Dust Industries
Washington, États-Unis
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Crystal Reports
Titre:
Pass ADO Recordset From Fox to a Crystal Report
Divers
Thread ID:
00677867
Message ID:
00677867
Vues:
65
I've created a CR 8.5 report, using the CR cross-tab expert. I created it using a temporary DBF with the same structure the RS will eventually have.

I've added a CR Viewer to a form, and I'm trying to pass a RS to the report to use instead of the table I used to create the report.

This pseudo code of what I'm doing in Fox:
* Declare  vars including:
LOCAL loConnection AS ADODB.CONNECTION, ;
loRS AS ADODB.RECORDSET, ;
loCommand AS ADODB.COMMAND, ;
loReport AS CrystalRuntime.REPORT, ;
loApp AS CrystalRuntime.Application

*!* Initialize variables including:
loApp = CREATEOBJECT('CrystalRuntime.Application')
loReport = loApp.OpenReport(SalesAnalysisTotal)
loReport.DiscardSavedData

*!* Create my SQL select based on user choices, detail isn't really important since RS gets created o.k.
lcCommand = "SELECT blah, blah, etc"

*!* Create the connection
loConnection = CREATEOBJECT("ADODB.Connection")
loConnection.Mode = 16 && adModeShareDenyNone
lcConnection = ;
	"Provider=VFPOLEDB.1;" + ;
	"Data Source=" + CURDIR() + "DATA\;" + ;
	"Mode=Share Deny None;"
loConnection.OPEN(lcConnection)

*!* Create the recordset
loRS 	= CREATEOBJECT("ADODB.RecordSet")
loRS.LockType = 1 && Started with 3
loRS.CursorLocation = 2 && Started with 3
loRS.OPEN(lcCommand, loConnection) && Returns several thousand records as expected.

ASSERT loRS.RecordCount > 0 MESSAGE "No records returned!"

loReport.DiscardSavedData() && Altho the report is not saved with data, just for jollies.
loReport.DATABASE.SetDataSource(loRS,3,1) && Try and exchange the development source with the recordset.

toCrViewer.ReportSource = loReport
toCrViewer.ViewReport()
When the report runs, CR reports that no records were selected and that there was error in the database dll. This is no doubt because the temporary table I used to create the report doesn't exist any longer. This tells me Crystal isn't using the RS I passed, but I have no idea why.

TIA.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform