Print Page | Close Window

SetDataSource and ConnectionInfo

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Data Connectivity
Forum Discription: How to connect to data sources and export reports
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=9814
Printed Date: 29 Apr 2024 at 6:43am


Topic: SetDataSource and ConnectionInfo
Posted By: bembi
Subject: SetDataSource and ConnectionInfo
Date Posted: 26 Apr 2010 at 6:54am
Hi,

My report uses a stored procedure as datasource.
But in my .Net app I want to set the data of my report myself with the method:

<code>
rptDoc.SetDataSource(myDataSet)
</code>

I don't want to the report to get the data again with the stored procedure.
I export my report and using a DB profiler I found out that the report executes the stored procedure during export again.
I want the report to use the datasource I set and not more.

What do I have to do to achive that?
I thought I just don't set the Logon info and parameter values so the report can't connect to a DB. But then export doesn't work. any ideas?

thanks and bye
juergen



Replies:
Posted By: hilfy
Date Posted: 26 Apr 2010 at 12:13pm

In Visual Studio, edit the Crystal report and set the Datasource Location to the dataset in your application instead of to the stored procedure.  If you haven't explicitly defined the dataset, you'll have to.

Another option that I've used for this is to define an XML schema that matches your dataset.  Set the Datasource Location in the report to the XML schema.
 
For either of these solutions you'll have to keep you SetDataSource code so that the report will actually point to a dataset that contains data.
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: bembi
Date Posted: 26 Apr 2010 at 9:46pm
Hi,

thanks for the reply.
I am not sure how to set the database location to DataSet actually.

the property

<code>
rptDoc.Database.Tables[0].Location
</code>

is a string. what do I have to set there? And what about the ConnectionInfo and Parameters. Can I just leave them?

bye juergen



Posted By: hilfy
Date Posted: 27 Apr 2010 at 3:23am
You still use your original code of
 
rptDoc.SetDataSource(myDataSet)
 
in your application code.
 
In the Crystal Designer, you go to the Crystal menu, Database, Set Location to change from the stored procedure to the data definition that's in your application.
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: bembi
Date Posted: 27 Apr 2010 at 4:53am
Ah OK,

I thought I could change the location to DataSet im my .Net application :-(
I need the report with a stored procedure location as well.

I guess I have to make 2 versions of the same report?

juergen



Posted By: hilfy
Date Posted: 27 Apr 2010 at 5:56am
Probably.  Crystal can be very quirky about how it handles stored procedures.  It can see the result set as a table, but it doesn't treat the definition/link to the stored procedure as if it were a table so resetting the data source location in code doesn't always work unless you're setting it to another stored procedure - even then there can be issues.
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics



Print Page | Close Window