Results 1 to 7 of 7

Thread: Load Report Failed???

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Load Report Failed???

    I have a crystal report in which I am trying to create and view. When I try and run the report from a VB.Net app, I get the above error. Now I know that this is because the report can't be found. In my project, I have defined a "Report" directory where all my reports will go. My problem is I'm not sure how to define that location for the "rpt.Load(path)" statement. Here is what I have so far!

    Code:
        Public Sub ClientListing()
            Try
                Dim rpt As ReportDocument = New ReportDocument
                Dim rptName As String = "\client_MasterListing.rpt"
    
                If client.SelectClient(True) Then
                    rpt.Load(rptName)
                    rpt.Database.Tables(0).SetDataSource(client.dsClients)
                    frmReports.crViewer.ReportSource = rpt
                End If
    
            Catch ex As Exception
                MessageBox.Show(ex.Message, "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
        End Sub
    Blake

  2. #2
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    Re: Load Report Failed???

    Code:
    Dim rptName As String = "C:\Report\client_MasterListing.rpt"
    Also, study this general information about VB.NET & Crystal Reports , it could be helpful
    -----------------------------------------------------------------------------------

    'To pass logon information to a Crystal Report at runtime

    Code:
    Imports CrystalDecisions.CrystalReports.Engine
    Imports CrystalDecisions.Shared
    
    Dim crtableLogoninfos As New TableLogOnInfos()
    Dim crtableLogoninfo As New TableLogOnInfo()
    Dim crConnectionInfo As New ConnectionInfo()
    Dim CrTables As Tables
    Dim CrTable As Table
    Dim TableCounter
    'If you are using a Strongly Typed report (Imported in your project) named CrystalReport1.rpt use the following:
    Code:
    Dim crReportDocument As New CrystalReport1()
    'If you are using a Non-Typed report, and loading a report outside of the project, use the following:
    Code:
    Dim crReportDocument As New ReportDocument()
    
    crReportDocument.Load("c:\myReports\myReport.rpt")
    'Set the ConnectionInfo properties for logging on to the Database

    'If you are using ODBC, this should be the DSN name NOT the physical server name.
    'If you are NOT using ODBC, this should be the physical server name
    Code:
    With crConnectionInfo
        .ServerName = "DSN or Server Name"
    'If you are connecting to Oracle there is no DatabaseName. Use an empty string. For example, .DatabaseName = ""
        .DatabaseName = "DatabaseName"
        .UserID = "Your User ID"
        .Password = "Your Password"
    End With
    'This code works for both user tables and stored procedures.
    'Set the CrTables to the Tables collection of the report
    Code:
    CrTables = crReportDocument.Database.Tables
    
    'Loop through each table in the report and apply the LogonInfo information
    For Each CrTable in CrTables
        CrTableLogonInfo = CrTable.LogonInfo
        CrTableLogonInfo.ConnectionInfo = crConnectionInfo
        CrTable.ApplyLogOnInfo(crtableLogoninfo)
    
        'If your DatabaseName is changing at runtime, specify the table location.
        'For example, when you are reporting off of a Northwind database on SQL server you should have the following line of code:
        crTable.Location = "Northwind.dbo." & crTable.Location.Substring(crTable.Location.LastIndexOf(".") + 1)
    Next
    
    
    'Set the viewer to the report object to be previewed.
    CrystalReportViewer1.ReportSource = crReportDocument
    ----------------------------------------------
    Also it may help that you visit --->
    https://boc.sdn.sap.com/taxonomy/term/3
    ----------------------------------------------


    If you are changing database at runtime, it is important that you specify the table location after you apply logon information (this is a case sensitive property).
    You can either specify the table name only or the fully qualified table name such as
    crTable.location = "databaseName.dbo.tablename"

    Refer to knowledge base article c2010275 if you wish to change database logon information in the main and subreport.

    If you are reporting off an Access database, then specify either the 'ServerName' or 'DatabaseName' to the 'ConnectionInfo' Object depending on how you are connecting to Access.

    For example, if you are connecting to Access through ODBC, then set the 'DatabaseName' for the 'ConnectionInfo' object as follows:
    Code:
    With crConnectionInfo
        .DatabaseName = "C:\mydatabase\mydata.mdb"
    End With
    If you are connecting to Access through OLE DB, then set set the 'ServerName':
    Code:
    With crConnectionInfo
        .ServerName = "C:\mydatabase\mydata.mdb"
    End With
    It is not possible to report of a secured Access database using a native connection.
    See knowledge base article C2010460 for more information.

    If you are using more than one database with different usernames and passwords, use a loop to pass in the different values.

    JG

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Load Report Failed???

    Unfortunately this code isn't working. I'm obviously missing something else....
    Blake

  4. #4
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    910

    Re: Load Report Failed???

    I like these examples, but does anyone know what to do if you are using two databases and some tables go with one connection and other tables go with another connnection?

  5. #5
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    Re: Load Report Failed???

    Inside the loop where you ask for each table you could set a condition
    If the table=x then connectioninfo1
    If the table=y then connectioninfo2

    JG

  6. #6
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    910

    Re: Load Report Failed???

    Actually only one of the databases requires a login so I did this
    Code:
     cr.Database.Tables("WORKORDER").ApplyLogOnInfo(crtableLogoninfo)
    Quote Originally Posted by jggtz View Post
    Inside the loop where you ask for each table you could set a condition
    If the table=x then connectioninfo1
    If the table=y then connectioninfo2

    JG

  7. #7
    New Member
    Join Date
    May 2010
    Posts
    1

    Re: Load Report Failed???

    I accept with information:
    Inside the loop where you ask for each table you could set a condition
    If the table=x then connectioninfo1
    If the table=y then connectioninfo2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width