cancel
Showing results for 
Search instead for 
Did you mean: 

crystalreportviewer

Former Member
0 Kudos

hi, I want to change the conecction to my report on ejecution time, I'm working with visual basic 2005 and crystal reports 2008, but I just can't do that because the report(using the crystalreport viewer to see the report) doesn't change the database nor the server, I have been trying with the next code

firts:

Imports CrystalDecisions.Shared

Imports CrystalDecisions.CrystalReports.Engine

next:

Dim crTableLogonInfo As New TableLogOnInfo

Dim crConnectionInfo As New ConnectionInfo

next: crvhistorial is the name of the crystalreportviewer

Private Sub SetDBLogonForReport(ByVal myConnectionInfo As ConnectionInfo)

Dim crTableLogonInfos As TableLogOnInfos = Me.crvhistorial.LogOnInfo

For Each myTableLogOnInfo As TableLogOnInfo In crTableLogonInfos

myTableLogOnInfo.ConnectionInfo = myConnectionInfo

Next

End Sub

Private Sub ConfigureCrystalReports()

Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()

myConnectionInfo.IntegratedSecurity = True

myConnectionInfo.DatabaseName = dll.conexionsql.Database

myConnectionInfo.ServerName = dll.conexionsql.DataSource

SetDBLogonForReport(myConnectionInfo)

End Sub

and:

at the from's load I call the procedure: ConfigureCrystalReports()

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Try this code,


Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Web
Imports CrystalDecisions.Shared
 
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
        Dim crTables As Tables
        Dim crDatabase As Database
        Dim crConnectioninfo As ConnectionInfo
        Dim crTablellogonInfo As TableLogOnInfo
 
        Dim rd As New ReportDocument()
        rd.Load("Give here the path of your report")
 
        crConnectioninfo = New ConnectionInfo()
        crConnectioninfo.ServerName = ""
        crConnectioninfo.DatabaseName = ""
        crConnectioninfo.UserID = ""
        crConnectioninfo.Password = ""
 
        crDatabase = rd.Database
        crTables = crDatabase.Tables
 
        For Each crTable As CrystalDecisions.CrystalReports.Engine.Table In crTables
            crTablellogonInfo = crTable.LogOnInfo
            crTablellogonInfo.ConnectionInfo = crConnectioninfo
            crTable.ApplyLogOnInfo(crTablellogonInfo)
            crTable.Location = crTable.Location
        Next
 
    CrystalReportViewer1.ReportSource = rd
    End Sub
  

[See Also|http://devlibrary.businessobjects.com/BusinessObjectsXIR2/en/devsuite.htm]

Hope this helps!

Sincerely,

Nikhil Dharme

Answers (1)

Answers (1)

Former Member
0 Kudos

ok, thanks you, myquestion has been answered