473,289 Members | 1,953 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,289 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 9437
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.