473,418 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

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 9449
Hi, maybe this can help:

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.ReportSource

Private crParameterFields As New ParameterFields
Private crReportDocument As New ReportDocument

Public Sub InitialiseReport(ByVal psReportName As String, ByVal psTitle As
String)
Dim tblCurrent As Table
Dim crSubreportObject As SubreportObject
Dim subRepDoc As New ReportDocument
Dim crDatabase As
CrystalDecisions.CrystalReports.Engine.Database
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 crpConnectionInfo As New
CrystalDecisions.Shared.ConnectionInfo
Dim crpTableLogOnInfo As New
CrystalDecisions.Shared.TableLogOnInfo
crReportDocument.Load(psReportName)
CrystalReportViewer1.ReportSource = crReportDocument

'
' change server for main report
'
With crpConnectionInfo
.ServerName = "yourservername"
.DatabaseName = "yourdatabase"
End With

'if integrated security isn't true

crpConnectionInfo.UserID = "userid"
crpConnectionInfo.Password = "password"
For Each tblCurrent In crReportDocument.Database.Tables
crpTableLogOnInfo = tblCurrent.LogOnInfo
crpTableLogOnInfo.ConnectionInfo = crpConnectionInfo
tblCurrent.ApplyLogOnInfo(crpTableLogOnInfo)
Next

'Set the sections collection with report sections
crSections = crReportDocument.ReportDefinition.Sections
For Each crSection In crSections
crReportObjects = crSection.ReportObjects
For Each crReportObject In crReportObjects
If crReportObject.Kind =
ReportObjectKind.SubreportObject Then

'If you find a subreport, typecast the reportobject
to a subreport object
crSubreportObject = CType(crReportObject,
SubreportObject)

'Open the subreport
subRepDoc =
crSubreportObject.OpenSubreport(crSubreportObject. SubreportName)

crDatabase = subRepDoc.Database
crTables = crDatabase.Tables

'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 crpConnectionInfo
.ServerName =
FalProjectFuncties.OphalenConfigWaarde("CrystalRep ort", "Servernaam")
.DatabaseName =
FalProjectFuncties.OphalenConfigWaarde("CrystalRep ort", "Database")
End With
crLogOnInfo = crTable.LogOnInfo
crLogOnInfo.ConnectionInfo = crpConnectionInfo
crTable.ApplyLogOnInfo(crLogOnInfo)
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***@dynamictech.com.hk> schreef in bericht
news:#B**************@tk2msftngp13.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.phx.gb l...
Hi, maybe this can help:

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.ReportSource

Private crParameterFields As New ParameterFields
Private crReportDocument As New ReportDocument

Public Sub InitialiseReport(ByVal psReportName As String, ByVal psTitle As
String)
Dim tblCurrent As Table
Dim crSubreportObject As SubreportObject
Dim subRepDoc As New ReportDocument
Dim crDatabase As
CrystalDecisions.CrystalReports.Engine.Database
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 crpConnectionInfo As New
CrystalDecisions.Shared.ConnectionInfo
Dim crpTableLogOnInfo As New
CrystalDecisions.Shared.TableLogOnInfo
crReportDocument.Load(psReportName)
CrystalReportViewer1.ReportSource = crReportDocument

'
' change server for main report
'
With crpConnectionInfo
.ServerName = "yourservername"
.DatabaseName = "yourdatabase"
End With

'if integrated security isn't true

crpConnectionInfo.UserID = "userid"
crpConnectionInfo.Password = "password"
For Each tblCurrent In crReportDocument.Database.Tables
crpTableLogOnInfo = tblCurrent.LogOnInfo
crpTableLogOnInfo.ConnectionInfo = crpConnectionInfo
tblCurrent.ApplyLogOnInfo(crpTableLogOnInfo)
Next

'Set the sections collection with report sections
crSections = crReportDocument.ReportDefinition.Sections
For Each crSection In crSections
crReportObjects = crSection.ReportObjects
For Each crReportObject In crReportObjects
If crReportObject.Kind =
ReportObjectKind.SubreportObject Then

'If you find a subreport, typecast the reportobject
to a subreport object
crSubreportObject = CType(crReportObject,
SubreportObject)

'Open the subreport
subRepDoc =
crSubreportObject.OpenSubreport(crSubreportObject. SubreportName)

crDatabase = subRepDoc.Database
crTables = crDatabase.Tables

'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 crpConnectionInfo
.ServerName =
FalProjectFuncties.OphalenConfigWaarde("CrystalRep ort", "Servernaam")
.DatabaseName =
FalProjectFuncties.OphalenConfigWaarde("CrystalRep ort", "Database")
End With
crLogOnInfo = crTable.LogOnInfo
crLogOnInfo.ConnectionInfo = crpConnectionInfo
crTable.ApplyLogOnInfo(crLogOnInfo)
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***@dynamictech.com.hk> schreef in bericht
news:#B**************@tk2msftngp13.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***@dynamictech.com.hk> schreef in bericht
news:eM*************@TK2MSFTNGP09.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.phx.gb l...
Hi, maybe this can help:

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.ReportSource

Private crParameterFields As New ParameterFields
Private crReportDocument As New ReportDocument

Public Sub InitialiseReport(ByVal psReportName As String, ByVal psTitle As String)
Dim tblCurrent As Table
Dim crSubreportObject As SubreportObject
Dim subRepDoc As New ReportDocument
Dim crDatabase As
CrystalDecisions.CrystalReports.Engine.Database
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 crpConnectionInfo As New
CrystalDecisions.Shared.ConnectionInfo
Dim crpTableLogOnInfo As New
CrystalDecisions.Shared.TableLogOnInfo
crReportDocument.Load(psReportName)
CrystalReportViewer1.ReportSource = crReportDocument

'
' change server for main report
'
With crpConnectionInfo
.ServerName = "yourservername"
.DatabaseName = "yourdatabase"
End With

'if integrated security isn't true

crpConnectionInfo.UserID = "userid"
crpConnectionInfo.Password = "password"
For Each tblCurrent In crReportDocument.Database.Tables
crpTableLogOnInfo = tblCurrent.LogOnInfo
crpTableLogOnInfo.ConnectionInfo = crpConnectionInfo
tblCurrent.ApplyLogOnInfo(crpTableLogOnInfo)
Next

'Set the sections collection with report sections
crSections = crReportDocument.ReportDefinition.Sections
For Each crSection In crSections
crReportObjects = crSection.ReportObjects
For Each crReportObject In crReportObjects
If crReportObject.Kind =
ReportObjectKind.SubreportObject Then

'If you find a subreport, typecast the reportobject to a subreport object
crSubreportObject = CType(crReportObject,
SubreportObject)

'Open the subreport
subRepDoc =
crSubreportObject.OpenSubreport(crSubreportObject. SubreportName)

crDatabase = subRepDoc.Database
crTables = crDatabase.Tables

'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 crpConnectionInfo
.ServerName =
FalProjectFuncties.OphalenConfigWaarde("CrystalRep ort", "Servernaam")
.DatabaseName =
FalProjectFuncties.OphalenConfigWaarde("CrystalRep ort", "Database")
End With
crLogOnInfo = crTable.LogOnInfo
crLogOnInfo.ConnectionInfo = crpConnectionInfo crTable.ApplyLogOnInfo(crLogOnInfo)
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***@dynamictech.com.hk> schreef in bericht
news:#B**************@tk2msftngp13.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**************@TK2MSFTNGP12.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******@spammersgoawayintegrasol.dk> schreef in bericht
news:#w**************@TK2MSFTNGP10.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**************@TK2MSFTNGP12.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*************@TK2MSFTNGP09.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******@spammersgoawayintegrasol.dk> schreef in bericht
news:#w**************@TK2MSFTNGP10.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**************@TK2MSFTNGP12.phx.gbl...


Nov 23 '05 #7

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

Similar topics

1
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
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
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: ......
6
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....
1
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....
0
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...
0
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...
2
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...
2
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...
0
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...

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.