Solved

VB.Net Crystal Reports and Dynamic Datasource

Posted on 2013-11-07
5
1,346 Views
Last Modified: 2013-11-12
I am creating a vb.net application with sql server 2008/2012 backend.  This will be deployed to different police departments, which of course will have different server names.  I am trying to create the reports using crystal reports.

I did some research on how to set the connection info in the backend code, however during the design of the crystal reports how do I set this up?  Do I need to create a .xsd file and link it?  Or if I set the datasource inside the crystal reports design to my development database, will the code-behind (that changes the datasource) override the datasource selection when I designed the crystal report?

I'm confused, any advice?
0
Comment
Question by:K-9
5 Comments
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
Probably the easiest method to handle this is to feed the data to the reports using a dataset.

This link has sample code for doing that
http://www.emoreau.com/Entries/Articles/2006/09/Feeding-Crystal-Reports-from-your-application.aspx

THe beauty of doing it this way is that the application creates the dataset and it is easy to configure the opening of the database in code where as changing the data source of the report can at times be problematic.  WHat works for one doesn't always work for another.

Another idea used on a project where I built the reports.  The application created XML files for the data and the reports were built against them.  The XML files were stored in a known location (application specific) on the system and the reports again didn't have to be changed for different users.

If you want to hit the database directly, you simply build your reports against the development database then the code can be written to change the data source.  The report isn't built in any special way.

mlmcc
0
 
LVL 18

Expert Comment

by:vasto
Comment Utility
There are 2 ways to show data in Crystal :
 - PUSH (get the data in a dataset and pass it to the report)
 - PULL (set connection info and ask the report to retrieve the data)
No matter which one you will use you need to save somewhere the connection string to the database. .NET provides a standard way to do this using connectionsettings section in app.config file. You can also encrypt this section.

Is this a Web  application?
0
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 500 total points
Comment Utility
yes passing a dataset already filled to your report is the best way to go.

my article also has a second part @ http://www.emoreau.com/Entries/Articles/2006/10/Crystal-Reports--Part-II.aspx
0
 
LVL 22

Expert Comment

by:Ido Millet
Comment Utility
Why not use ODBC DSN as the data source?
Each police department would simply point the DSN to a different server.
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
WHy did you accept that as the answer?  The first part of his article is essential to the solution?

mlmcc
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

771 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

12 Experts available now in Live!

Get 1:1 Help Now