473,772 Members | 2,448 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Crystal Report Database Change

Hi, I've designed several Crystal Reports using the built in wizard.
They point to my database as HQ which is called "Thom". There is a
database called Sales on Thom which all the reports point to and get
their results from.

I'm ready to compile my program to give to the users at a different
site. They have a database server there called "Sidney" which had a
copy of the same "Sales" database on there. Is there a way I can
change the database of my report when I load it each time, it looks
like I'd have to go through each individual report and change the
database settings which would be very time consuming as I will be using
quite a few database servers with this program. I'd like to just
specify a database or dataset in the code.

This is how I call the report:

Dim Cr As New crRefunds

CrystalReportVi ewer1.ReportSou rce = Cr

it would be ideal if I could put a line in above, something like
cr.database = "Sidney". Is anything like this possible? If not what
is the best way to switch the database?

Any help or pointers will be greatly appreciated as I'm really stuck
with this one.

Nov 21 '05 #1
2 1708
Maybe this code can help you, I use it to run my reports on different db's
ofcourse the tablenames have to be the same.

hth Greetz Peter

add reference to CrystalDecision s.CrystalReport s.Engine.dll

Imports CrystalDecision s.CrystalReport s.Engine
Imports CrystalDecision s.Shared
Imports CrystalDecision s.ReportSource

Dim tblCurrent As Table
Dim crSubreportObje ct As SubreportObject
Dim subRepDoc As New ReportDocument
Dim crDatabase As CrystalDecision s.CrystalReport s.Engine.Databa se
Dim crTables As Tables
Dim crTable As Table
Dim crSection As Section
Dim crSections As Sections
Dim crReportObjects As ReportObjects
Dim crReportObject As ReportObject
Dim crLogOnInfo As TableLogOnInfo
Dim crpConnectionIn fo As New CrystalDecision s.Shared.Connec tionInfo
Dim crpTableLogOnIn fo As New CrystalDecision s.Shared.TableL ogOnInfo
Dim crReportDocumen t As New ReportDocument
crReportDocumen t.Load(psReport Name)
CrystalReportVi ewer1.ReportSou rce = crReportDocumen t
CrystalReportVi ewer1.Zoom(2)
'
' Aanpassen server voor hoofdrapport
'
With crpConnectionIn fo
.ServerName = "Yourserver "
.DatabaseName = "YourDataBa se"
End With

'set this if you don't work with integrated security
'crpConnectionI nfo.UserID = "user"
'crpConnectionI nfo.Password = "password"
For Each tblCurrent In crReportDocumen t.Database.Tabl es
crpTableLogOnIn fo = tblCurrent.LogO nInfo
crpTableLogOnIn fo.ConnectionIn fo = crpConnectionIn fo
tblCurrent.Appl yLogOnInfo(crpT ableLogOnInfo)
Next

'Set the sections collection with report sections
crSections = crReportDocumen t.ReportDefinit ion.Sections
For Each crSection In crSections
crReportObjects = crSection.Repor tObjects
For Each crReportObject In crReportObjects
If crReportObject. Kind = ReportObjectKin d.SubreportObje ct
Then

'If you find a subreport, typecast the reportobject to a
subreport object
crSubreportObje ct = CType(crReportO bject,
SubreportObject )

'Open the subreport
subRepDoc =
crSubreportObje ct.OpenSubrepor t(crSubreportOb ject.SubreportN ame)

crDatabase = subRepDoc.Datab ase
crTables = crDatabase.Tabl es

'Loop through each table and set the connection info
'Pass the connection info to the logoninfo object then
apply the
'logoninfo to the subreport

For Each crTable In crTables
With crpConnectionIn fo
.ServerName = "YourServer "
.DatabaseName = "YourDataBa se"
End With
crLogOnInfo = crTable.LogOnIn fo
crLogOnInfo.Con nectionInfo = crpConnectionIn fo
crTable.ApplyLo gOnInfo(crLogOn Info)
Next
End If
Next
Next
"Jasper Jones" <ja*******@gmai l.com> schreef in bericht
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
Hi, I've designed several Crystal Reports using the built in wizard.
They point to my database as HQ which is called "Thom". There is a
database called Sales on Thom which all the reports point to and get
their results from.

I'm ready to compile my program to give to the users at a different
site. They have a database server there called "Sidney" which had a
copy of the same "Sales" database on there. Is there a way I can
change the database of my report when I load it each time, it looks
like I'd have to go through each individual report and change the
database settings which would be very time consuming as I will be using
quite a few database servers with this program. I'd like to just
specify a database or dataset in the code.

This is how I call the report:

Dim Cr As New crRefunds

CrystalReportVi ewer1.ReportSou rce = Cr

it would be ideal if I could put a line in above, something like
cr.database = "Sidney". Is anything like this possible? If not what
is the best way to switch the database?

Any help or pointers will be greatly appreciated as I'm really stuck
with this one.

Nov 21 '05 #2
This looks good, Peter. I will try this out now. Many thanks.

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1130
by: Grant Stanley | last post by:
I'm developing an application in VS.Net 2003 using C#, which uses Crystal Reports. When creating each report, crystal asks where the database to use is, so I specify our SQL server using the ADO option. The problem is that these database settings seem to get compiled into the report, so when we take the application to our client it won't work on their systems. Before running each report I run some code which is ment to reset the...
7
4031
by: Phin | last post by:
I need your HELP! I've seen all the posts on using Crystal Reports within vs.net (vb.net) and changing a SQL query at runtime. When I tried to pass in a dataset into the crystal report at runtime, the report still showed the results from the default query (from within the Crystal Report). Then I tried the XSD solution where you define a dataset (that mataches the database and the Crystal Report) and have the Crystal Report use this....
3
5245
by: Diggler | last post by:
I was working on a report that is populated with three different tables in a strongly-typed dataset. The tables are populated from custom objects rather than directly from SQL Server. I loop through the objects and add the rows one at a time. I then push the dataset to the Crystal Report. The report worked fine, until this morning. I added another field or two to the dataset, and rearranged the report fields to organize the report...
7
2209
by: Bernie Yaeger | last post by:
I can't believe that there aren't lots of developers who: 1. create a crystal report that connects to sql server 2. calls the report using the crystalreportviewer control to view it and then, if appropriate, print it 3. tries to deploy that report to the client's database, but now it calls for a different database name Yet I can't get an answer to the question: I have developed numerous reports in an app (Windows Database App) that...
7
11250
by: Henry | last post by:
I am writing a Windows forms VB.Net/MS SQL application via VS 2003 that utilizes Crystal Reports. I want to be able to dynamically set the report data source at run time. I'm trying to change the the reports "integrated security" from TRUE to FALSE via the "Set Location" dialog in the report designer with no success. It is not intuitive (at least not to me.) I get the following error:
0
1872
by: Ray | last post by:
Dear all, Now I am using the report document in vb.net to call the crystal report and I will set the database information in the report document. The code is as follow: ... ReportTemp.Load(_reportname) For Each table In ReportTemp.Database.Tables logoninfo = table.LogOnInfo With logoninfo.ConnectionInfo .ServerName = "Server"
0
2273
by: Chris | last post by:
I have the following situation in a VB.Net App I am working on: 1.)A report created in VS.Net 2003 using the CR.Net component of VS 2003. 2.)The datasource for the report is a Stored Proc in a SQL Server DB (pull method). 3.)The Stored Proc has two input parameters of type date. 4.)The Stored Proc is a rather complex proc that was not written by me, but does work(see next item). It currently returns about 13K rows of data. 5.)The...
0
2533
by: Crash | last post by:
Hello everyone, I need help creating an asp page to view a crystal report, which requires that that I change the database connection dynamically. I thought I had this problem licked in CR7 (the version of crystal the report has been designed in) but when I tried to deploy CR7 to my server I found that I could not install the ASP components on IIS 6.0 (even using the manual installation method). I had a CR9 dev edition update, which came...
5
3738
by: jmar | last post by:
I posted a week ago and received one response. I'm looking for the opinion of several experienced .NET people before I proceed so I'm posting again. Sorry for the repost... I am updating a VB4.0 quote generation program to VB.net. The old program takes user inputs, performs calculations, saves the data to Access databases and uses Crystal Reports 5.0 to generate a quote. A while back users obviously wanted to be able to edit/e-mail ...
7
6718
by: Jlo | last post by:
Hi, I have a c# winforms application. When I call the report file, it shows me all the records in the table. How can I make it to call only a particular range. i have the following code Viewer1.ReportSource = Application.StartupPath + "//Label.rpt"; How can I assign it a dataset which have the data of a particular range.
0
9619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10103
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8934
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.