Solved

Redirect Datasource at runtime

Posted on 2003-12-11
7
2,066 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 Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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. …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

820 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