vb.net - Unable to add tables to Crystal Reports

Background: I have an old report in which I am trying to add a table and a field. The report works perfectly fine in my web application. (Crystal reports ver. 11.5.9.1076)

After adding a table I get the error:

System.Runtime.InteropServices.COMException: Failed to open connection

This happens whether I add a table, command, or stored procedure to the report. (Connecting to Oracle database)

Things I've tried:

  • Add table (crashes), remove table (works again)
  • Click the "Verify database" button in the Database menu
  • Set database location and update the newly added table
  • Previewing the report seems to work

As for how I'm providing the data:

  1. Create and load ReportDocument (VB.net)
  2. Populate DataSet
  3. Call SetDataSource method with DataSet as param
  4. ExportToHttpResponse as PortableDocFormat

1 Answer

  1. Jesse- Reply

    2020-02-23

    Here is what we had to do in order to make this work in our crystal reports: after loading the report, we loop through each of the DataSourceConnections in the report and update the connection information.

    For Each oConnection As IConnectionInfo In oReport.DataSourceConnections
        If fUseIntegratedSecurity Then
            oConnection.SetConnection(sServerName, sDatabaseName, True)
        Else
            oConnection.IntegratedSecurity = False
            oConnection.SetConnection(sServerName, sDatabaseName, sUserLogon, sUserPassword)
        End If
    Next
    

    The actual connection details are provided elsewhere in our app, so I am just showing placeholders in the code above.

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>