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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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"?
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


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
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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


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
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
 
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.