Solved

VB.Net Crystal Reports and Dynamic Datasource

Posted on 2013-11-07
5
1,449 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 39630217
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
ID: 39630405
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 70

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 39630414
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 23

Expert Comment

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

Expert Comment

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

mlmcc
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

623 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