Solved

Redirect Datasource at runtime

Posted on 2003-12-11
7
2,064 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

863 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

26 Experts available now in Live!

Get 1:1 Help Now