Solved

Redirect Datasource at runtime

Posted on 2003-12-11
7
2,063 Views
Last Modified: 2007-12-19
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


0
Comment
Question by:zerobro
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 13

Expert Comment

by:EwaldL
ID: 9923228
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
 
LVL 4

Expert Comment

by:jrmn
ID: 9925019
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
 

Expert Comment

by:yadav_surender
ID: 9927092
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 4

Accepted Solution

by:
jrmn earned 60 total points
ID: 9932587
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
 

Assisted Solution

by:yadav_surender
yadav_surender earned 40 total points
ID: 9933672
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
 
LVL 13

Expert Comment

by:EwaldL
ID: 9933832
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
 

Author Comment

by:zerobro
ID: 9961065
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

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now