Redirect Datasource at runtime

Hi Experts,

I have this code in Visual Foxpro 8 :
This is an old one because it is using Automation server.
Hope you guys can show me the right coding to work with RDC.

*/==========================================
oCRApplication = createobject("Crystal.CRPE.Application")
oCRReport = oCRApplication.OpenReport("E:\LAN Research\arcust.rpt", 1)
oCRReport.discardsaveddata
oCRReport.Database.tables(1).SetLogOnInfo("CRXML","","vamlogin","")
oCRReport.Database.tables(1).Location = "XML.myXMLFile"
oCRReport.Preview
*/==========================================

ARCUST.RPT (done using CR 8.5) is an rpt whose data source is a MSSQL 2000 stored procedure with 3 stored procedure parameters.

At Visual Foxpro Environment, I have a code that converts the VFP query resultset to an XML file (MyXMLFile.xml)

The fieldnames and datatype for both MSSQL SP and XML file is exactly the same.

Now, at runtime, I'd like to change the datasource of the RPT to point to this XML file (from the previously assigned MSSQL SP at design time).

The problem is that, when I issue the code above, a window pops up which requires me to enter Parameter Values (of the 3 MSSQL SP parameters).
Since I issue the logoninfo to point to an XML ODBC and supply the Location, I thought it will automatically preview the report which will then use the XML file.

What seems to be the problem?

Please show me code lines how to correct this.

Visual Basic 6 or Delphi  code lines is fine.

Thanks in advance,

zerobro


zerobroAsked:
Who is Participating?
 
jrmnCommented:
I don't think its possible to change datasource at runtime with CR 8.5.

Using Crystal Reports 9 it is possible to change the datasource at runtime. However I have not tested this against XML files.

If you have CR 9, please have a look at the help file CrystalDevHelp9.chm that may probably be located under \Program Files\Crystal Decisions\Crystal Reports 9\Developer Files\Help\En directory under the title "How to change the data source". This section contains the sample code demonstrating to change the data source at runtime.

Tip : Additionally have a look at the section under the title "Common Connection Properties" that explains the list of methods that may be used when changing the connection.

jrmn
0
 
EwaldLCommented:
was the report also created through odbc? this would be essential here. now i haven't worked with xml and crystal combined, but is there a password on the xml odbc source that you need to set the password "vamlogin"?
0
 
jrmnCommented:
Hi EwaldL,

Thanks for the reply.
Sorry, there's no password supplied here. I forgot to delete this one.
Yes the report was created (design time) through ODBC connected to MSSQL 2000 database.
Basically, what I wanted is a way to have crystal work both on MSSQL and XML datasources and CR report was originally created with MSSQL as datasource.

zerobro


0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
yadav_surenderCommented:
Hi
Instead that you can use the following code for giving runtime Location

First Declare a recordset of that table or source which you want to use to that report then write the following  code

Report.Database.SetDatasource rs,3,1

If you have more than one table then you can use the second recordset
Report.Database.SetDatasource rs1,3,2

Cheers
Surender
0
 
yadav_surenderCommented:
The code which I have written earlier is there if you are using CrystalReport Designer in VB6.
I have develop lot of software with using CR 8.5 and VB6.  So Please try above code and follow these guidlines.

First Add a Desinger of CrystalReport in VB
then desing a report and import the existing report
Decllare a object of that report and after that you can write this code


Surender


0
 
EwaldLCommented:
when changing the datasource at runtime, the seccond database's design needs to match the first's. as far as i know you can specify parameters in an xml file, so this might be the trouble maker. can you test your code with a report that connects to sql server without parameters in the stored procedure. is that working now? if it is a must to use both a parameterised stored proc and an xml file, then it's best to use the setdatasource as suggested by yadav_surender
0
 
zerobroAuthor Commented:
hi EwaldL,

The application that I'm making is actually using Automation Server (in Visual Foxpro envoronment).
I'm not the one who designed this but rather just taking over from another officemate.
I'm not yet that good with VFP but no choice at my end.

jrmn : you have a point because if I remember it right,  some months back I read a semilar problem to this posted on another cyrstal reports forum.
Your answer is the somewhat similar as what I've read there.

zerobro
 
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.