Data Connectivity
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Data Connectivity
Message Icon Topic: SetDataSource and ConnectionInfo Post Reply Post New Topic
Author Message
bembi
Newbie
Newbie


Joined: 15 Mar 2010
Online Status: Offline
Posts: 5
Quote bembi Replybullet Topic: SetDataSource and ConnectionInfo
    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
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet 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
IP IP Logged
bembi
Newbie
Newbie


Joined: 15 Mar 2010
Online Status: Offline
Posts: 5
Quote bembi Replybullet 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

IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet 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
IP IP Logged
bembi
Newbie
Newbie


Joined: 15 Mar 2010
Online Status: Offline
Posts: 5
Quote bembi Replybullet 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

IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet 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
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.000 seconds.