Re: VFP 9.0 ADO connection to Crystal Reports XI - want CR to select data not VFP
- From: bmuhl@xxxxxxxxxxxx
- Date: Mon, 19 May 2008 06:31:41 -0700 (PDT)
On May 15, 10:19 am, "Craig Berntson" <cr...@xxxxxxxxxxxxxxxxx> wrote:
I don't have Crystal XI installed here, but it should be the same as
connecting to any ADO data source. The CR Docs should explain how to do
this.
--
Craig Berntson
Microsoft MVP
-------------<bm...@xxxxxxxxxxxx> wrote in message
news:24505c25-3cd6-4429-9fbc-e9b3a8c6d34e@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I am new to Crystal reports and found Craig Berntson's article:
"http://www.craigberntson.com/articles/kb014.htm" to be extremely
useful. I can easily access Crystal Reports via VFP and print a
report that has already had the data saved. My problem is that I also
want to be able to access Crystal Reports and let it refresh the data
using the table selection criteria setup within CRXI.
The example below from his article shows how to establish the ADO
connection and pass the recordset with the SQL selection criteria.
Can anyone tell me how to open the connection and let CRXI perform the
selection?
Craig's example:
ADO Data
Using ADO data is a bit different than the previous data access
methods. Because ADO is an object held in memory, there is no physical
file for Crystal Reports to use. In this case, create the ADO
RecordSet and pass it to Crystal Reports.
LOCAL oCR AS CRAXDRT.Application
LOCAL oRpt AS CRAXDRT.Report
LOCAL oDB AS CRAXDRT.Database
LOCAL ocDBT AS CRAXDRT.DatabaseTables
LOCAL oDBT AS CRAXDRT.DatabaseTable
LOCAL oConn AS ADODB.Connection
LOCAL oRS AS ADODB.Recordset
* Handle the ADO stuff
oConn = CREATEOBJECT("ADODB.Connection")
oConn.ConnectionString = "Provider=VFPOLEDB.1;Data Source=C:\eFox\Data
\tastrade.dbc;Password=''"
oConn.Open()
oRS = CREATEOBJECT("ADODB.RecordSet")
oRS.Open("Select * FROM Customer", oConn) <---This is what I want CR
to perform
oCR = CREATEOBJECT("CrystalRuntime.Application")
oRpt = oCR.OpenReport("C:\EFox\ADO1.RPT")
* Create the Database object
oDB = oRpt.Database()
* Get a references to the DatabaseTables collection
ocDBT = oDB.Tables()
* Get a reference to the DatabaseTable object for table 1
oDBT = ocDBT.Item(1)
* Pass the Record Set to Crystal Reports
oDBT.SetDataSource(oRS) <--- example has this populated with select
criteria but I want to use CRIX select.
IF oRPt.HasSavedData
oRPT.DiscardSavedData() <--- I have this working and it prompts me
to enter my CR parameter but then I get
ENDIF error: Crystal Reports
Activex Designer failed to open conection...
oRpt.PrintOut()
Any advice would be greatly appreciated!!- Hide quoted text -
- Show quoted text -
I did get this to work by passing select criteria that doesn't return
any rows. If I omit the select then I get the connection error.
I also noticed that once control is passed to Crystal and the user is
prompted to enter the parameter criteria there are two buttons - OK
and Cancel. If the user clicks on cancel button the process gives an
OLE unknown database connector error.
BethAnn
.
- Follow-Ups:
- Re: VFP 9.0 ADO connection to Crystal Reports XI - want CR to select data not VFP
- From: Craig Berntson
- Re: VFP 9.0 ADO connection to Crystal Reports XI - want CR to select data not VFP
- References:
- Prev by Date: Runtime files for Crystal Reports 8.5 (VFP7 in W Vista)
- Next by Date: Re: VFP 9.0 ADO connection to Crystal Reports XI - want CR to select data not VFP
- Previous by thread: Re: VFP 9.0 ADO connection to Crystal Reports XI - want CR to select data not VFP
- Next by thread: Re: VFP 9.0 ADO connection to Crystal Reports XI - want CR to select data not VFP
- Index(es):