473,657 Members | 2,461 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change database name in crystal report ?

Please help, i had completed over 30-50 reports, now. our client insist to
change the database name.
anyshorcut that I can change the database name in the report without
re-write all of them ??
Thanks in advance
Nov 23 '05 #1
6 9465
Hi, maybe this can help:

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

Private crParameterFiel ds As New ParameterFields
Private crReportDocumen t As New ReportDocument

Public Sub InitialiseRepor t(ByVal psReportName As String, ByVal psTitle As
String)
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
crReportDocumen t.Load(psReport Name)
CrystalReportVi ewer1.ReportSou rce = crReportDocumen t

'
' change server for main report
'
With crpConnectionIn fo
.ServerName = "yourservername "
.DatabaseName = "yourdataba se"
End With

'if integrated security isn't true

crpConnectionIn fo.UserID = "userid"
crpConnectionIn fo.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 =
FalProjectFunct ies.OphalenConf igWaarde("Cryst alReport", "Servernaam ")
.DatabaseName =
FalProjectFunct ies.OphalenConf igWaarde("Cryst alReport", "Database")
End With
crLogOnInfo = crTable.LogOnIn fo
crLogOnInfo.Con nectionInfo = crpConnectionIn fo
crTable.ApplyLo gOnInfo(crLogOn Info)
Next
End If
Next
Next
End Sub

Hth greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.
"Agnes" <ag***@dynamict ech.com.hk> schreef in bericht
news:#B******** ******@tk2msftn gp13.phx.gbl...
Please help, i had completed over 30-50 reports, now. our client insist to
change the database name.
anyshorcut that I can change the database name in the report without
re-write all of them ??
Thanks in advance

Nov 23 '05 #2
Thank Peter, However, as i modify the report, it still link back to the old
database.
"Peter Proost" <pp*****@nospam .hotmail.com> ¼¶¼g©ó¶l¥ó·s»D: Oc************* @TK2MSFTNGP09.p hx.gbl...
Hi, maybe this can help:

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

Private crParameterFiel ds As New ParameterFields
Private crReportDocumen t As New ReportDocument

Public Sub InitialiseRepor t(ByVal psReportName As String, ByVal psTitle As
String)
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
crReportDocumen t.Load(psReport Name)
CrystalReportVi ewer1.ReportSou rce = crReportDocumen t

'
' change server for main report
'
With crpConnectionIn fo
.ServerName = "yourservername "
.DatabaseName = "yourdataba se"
End With

'if integrated security isn't true

crpConnectionIn fo.UserID = "userid"
crpConnectionIn fo.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 =
FalProjectFunct ies.OphalenConf igWaarde("Cryst alReport", "Servernaam ")
.DatabaseName =
FalProjectFunct ies.OphalenConf igWaarde("Cryst alReport", "Database")
End With
crLogOnInfo = crTable.LogOnIn fo
crLogOnInfo.Con nectionInfo = crpConnectionIn fo
crTable.ApplyLo gOnInfo(crLogOn Info)
Next
End If
Next
Next
End Sub

Hth greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.
"Agnes" <ag***@dynamict ech.com.hk> schreef in bericht
news:#B******** ******@tk2msftn gp13.phx.gbl...
Please help, i had completed over 30-50 reports, now. our client insist
to
change the database name.
anyshorcut that I can change the database name in the report without
re-write all of them ??
Thanks in advance


Nov 23 '05 #3
Hi in crystal reports you can go to Database and then select set datasource
location

hth Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.

"Agnes" <ag***@dynamict ech.com.hk> schreef in bericht
news:eM******** *****@TK2MSFTNG P09.phx.gbl...
Thank Peter, However, as i modify the report, it still link back to the old database.
"Peter Proost" <pp*****@nospam .hotmail.com>

¼¶¼g©ó¶l¥ó·s»D: Oc************* @TK2MSFTNGP09.p hx.gbl...
Hi, maybe this can help:

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

Private crParameterFiel ds As New ParameterFields
Private crReportDocumen t As New ReportDocument

Public Sub InitialiseRepor t(ByVal psReportName As String, ByVal psTitle As String)
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
crReportDocumen t.Load(psReport Name)
CrystalReportVi ewer1.ReportSou rce = crReportDocumen t

'
' change server for main report
'
With crpConnectionIn fo
.ServerName = "yourservername "
.DatabaseName = "yourdataba se"
End With

'if integrated security isn't true

crpConnectionIn fo.UserID = "userid"
crpConnectionIn fo.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 =
FalProjectFunct ies.OphalenConf igWaarde("Cryst alReport", "Servernaam ")
.DatabaseName =
FalProjectFunct ies.OphalenConf igWaarde("Cryst alReport", "Database")
End With
crLogOnInfo = crTable.LogOnIn fo
crLogOnInfo.Con nectionInfo = crpConnectionIn fo crTable.ApplyLo gOnInfo(crLogOn Info)
Next
End If
Next
Next
End Sub

Hth greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
"Agnes" <ag***@dynamict ech.com.hk> schreef in bericht
news:#B******** ******@tk2msftn gp13.phx.gbl...
Please help, i had completed over 30-50 reports, now. our client insist
to
change the database name.
anyshorcut that I can change the database name in the report without
re-write all of them ??
Thanks in advance



Nov 23 '05 #4
CT
>Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.


I just love your signature Peter... :-)
--
Carsten Thomsen
Communities - http://community.integratedsolutions.dk

"Peter Proost" <pp*****@nospam .hotmail.com> wrote in message
news:e9******** ******@TK2MSFTN GP12.phx.gbl...
Nov 23 '05 #5
I got it from the second link but on the first link there are also a lot of
fun quotes like this one:

Everyone knows that debugging is twice as hard as writing a program in the
first place. So if you're as clever as you can be when you write it, how
will you ever debug it? (Brian Kernighan)

http://www.sysprog.net/quotbugs.html

http://www.sysprog.net/quotpgmr.html

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.
"CT" <ca******@spamm ersgoawayintegr asol.dk> schreef in bericht
news:#w******** ******@TK2MSFTN GP10.phx.gbl...
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to producebigger and better idiots. So far, the Universe is winning.


I just love your signature Peter... :-)
--
Carsten Thomsen
Communities - http://community.integratedsolutions.dk

"Peter Proost" <pp*****@nospam .hotmail.com> wrote in message
news:e9******** ******@TK2MSFTN GP12.phx.gbl...

Nov 23 '05 #6
CT
Love them, thanks.

--
Carsten Thomsen
Communities - http://community.integratedsolutions.dk

"Peter Proost" <pp*****@nospam .hotmail.com> wrote in message
news:O0******** *****@TK2MSFTNG P09.phx.gbl...
I got it from the second link but on the first link there are also a lot of
fun quotes like this one:

Everyone knows that debugging is twice as hard as writing a program in the
first place. So if you're as clever as you can be when you write it, how
will you ever debug it? (Brian Kernighan)

http://www.sysprog.net/quotbugs.html

http://www.sysprog.net/quotpgmr.html

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.
"CT" <ca******@spamm ersgoawayintegr asol.dk> schreef in bericht
news:#w******** ******@TK2MSFTN GP10.phx.gbl...
>Programming today is a race between software engineers striving to build
>bigger and better idiot-proof programs, and the Universe trying to produce >bigger and better idiots. So far, the Universe is winning.


I just love your signature Peter... :-)
--
Carsten Thomsen
Communities - http://community.integratedsolutions.dk

"Peter Proost" <pp*****@nospam .hotmail.com> wrote in message
news:e9******** ******@TK2MSFTN GP12.phx.gbl...


Nov 23 '05 #7

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

Similar topics

1
1370
by: fanor | last post by:
Hi guys, How can I change at runtime the database for a report?? I need to do this, because my aplication would be installed in any directory. TIA
0
1193
by: kent | last post by:
I use crystal report 8.5 in Visual Studion .Net and encounter a problem now. I want to change an picture path at run time and want to save the picture in database. Does anyone know how to do?
0
1865
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"
6
2610
by: craigkenisston | last post by:
How to change database name on the fly? I have an asp.net application in which a user connects to a sql server, where there's a centralized database with the users table and general settings. Then, each user also has a database in which his particular information is stored. There will be a few hundreds of this databases. Certain groups of users will share a database, all tables in this database have a userid column for identification...
1
1165
by: Jason Huang | last post by:
Hi, Would someone tell how to connect my SQL Server 2000 Server to my Crystal Report which shipped with the VS 2003? The reason I asked is I can't find the Field Explorer in my Crystal Report. Thanks for help. Jason
0
1486
by: dilchahatahai | last post by:
Hi I am having a problem with crystal report . I can create a crystal reports . (new crystal report ->new->standerd->create new connection->dataset->choose data set->choose table ->add report field->....->) (In a form from tool box i choose crystal report viewer->set its propert for allready created crystal report) this is how i am able to get fields into the report but the problem is that how to add data (Rows) from table to...
0
1056
by: rami1999 | last post by:
Hi: I am having a problem in running Crystal reports against a cache database (the world fastest database) The reports runs very slow while extracting database record from a cache datase. Does anyone in the community have experience in running Crystal report on a cache datase. Please advsie. And how easy to link it on the web. Regards, Rami1999
2
2181
by: hmznzr | last post by:
i am using b.net 2005. i am generating a crystal report. but when i work in a different computer i have to set the location of the database of the report before i generate. is their any dynamic way to set my database location to the report.
2
4562
by: deegeorge | last post by:
Hi, I have an aspx form. In that i have a check box for Credit card payment. When i am submitting that form it need to open a crystal report. If the checkbox is checked the textbox field in crystal report should update with 'Credit Card Payment'. If the checkbox is not checked the textbox field in crystal report should update with 'Cash Payment'. How can i do this. I am filling other data in crystal report with dataset. Pls help...
0
8305
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
8823
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
8726
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...
0
7320
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...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4151
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
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1944
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1604
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.