Skip to Content
author's profile photo Former Member
Former Member

crystalreportviewer

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()

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 22, 2009 at 02:01 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 22, 2009 at 01:38 PM

    ok, thanks you, myquestion has been answered

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.