Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to use a Crystal Report on multiple Fox databases
Message
 
À
21/11/2005 10:38:20
Information générale
Forum:
Visual FoxPro
Catégorie:
Crystal Reports
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01070701
Message ID:
01070884
Vues:
18
Thanks for the link info. I did read the Crystal documents on your web site and have managed to create a report which works with two different Fox databases when I run it in Crystal Designer; i.e. when changing the Datasource Location in Crystal and the report runs on different Fox databases.

However, when I try to do the same programmatically I get an error.

The exact error I get is:-
Logon failed.
Details: ADO Error Code: 0x800300fb
Source: Microsoft OLE DB Service Components
Description: the file is not a valid compound file.
The Fox code is:-
* PreViewForm.Init()
LPARAMETERS pnDatabase, pcCompanyID
* Simple test to see if we can pass Database location and record ID as parameters to Crystal

this.oCrystalEngine = CREATEOBJECT("CrystalRuntime.Application")
this.oReport        = this.oCrystalEngine.OpenReport("C:\CRM_test\Test01.Rpt")

* set the data location according to first parameter passed to form
loTables	= this.oReport.Database.Tables
DO CASE	
    CASE pnDatabase=2
 	* use the USA demo database
	this.oReport.Database.setdatasource("c:\CRM_DATA\DEMODATA")
	FOR EACH loTable IN this.oReport.Database.Tables
	   loTable.Location = FORCEPATH(loTable.Location,"c:\CRM_DATA\DEMODATA")+".dbf"
	ENDFOR
    CASE pnDatabase=3
	* use the FinPlus database
         this.oReport.Database.setdatasource("c:\CRM_DATA\FINPLUS_LOCAL")
	FOR EACH loTable IN this.oReport.Database.Tables
	   loTable.Location = FORCEPATH(loTable.Location,"c:\CRM_DATA\FINPLUS_LOCAL")+".dbf"
	ENDFOR	
ENDCASE

WITH thisform.oleCRViewer
	.top 	= 1
	.left	= 1
	.height	= thisform.Height - 2
	.width	= thisform.Width - 2
	.reportsource	= thisform.oReport
	.EnablePrintButton = .T.
	.ViewReport()
ENDWITH
When executing the report in Crystal Designer the Properties of the DataSource are:-
    Database Type:  OLE DB (ADO)
    Provider: VFPOLEDB
    Data Source: c:\CRM_DATA\DEMODATA\crm.dbc
    User ID:
    Locale Identifier: 1033
    OLE DB Services: -5
    Collating Sequence: Machine
    DSN:
Any ideas why I get this error and how to fix it.

Thanks in advance.


>See the Crystal documents on my web site.
>
>>I want to write a Crystal Report and pass the VFP database as a parameter so that I can use the same report with multiple databases.
>>
>>Any advice on how to do this? (I am using Crystal v9)
>>
>>All the Crystal report examples I have seen use a DSN to access a VFP database, but it is not practical to create a new DSN everytime I want to access a different database.
>>
>>Thanks in advance.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform