Changing Connection parameters in a Crystal 11 report

Posted on 2006-05-05
Last Modified: 2008-01-09
I have a crystal 11 report, running from a SQL server stored procedure.

I am using VB6 code to run the report.
I am using CRAXDDRT in the VB6 project.

I am using the ConnectionProperties of the table to set the security, server and initial catalog.

the problem is, if I want to change the name of the SQL server database (for upgrading purposes), the report still attempts to connect to the old database name.

This is causing a problem because if the original database does not exist the program will not run.

Any ideas?
Question by:PaulPattinson
    LVL 100

    Expert Comment

    Does your report have subreports?


    Author Comment

    Yes. It has 3 subs.

    Author Comment

    The subreport connection properties are being set using the same logic as the main report.
    LVL 100

    Expert Comment

    Can you show the  code?


    Author Comment

    This is the code i am using to set the connection paramrters for each table in the report/subreports :

    I took this from the Crystal Reports Technical reference guide . pdf

    Private Sub SetTableLogonInfo(i_objReportTable As CRAXDDRT.DatabaseTable)

    Dim objConnectionProperty As CRAXDDRT.ConnectionProperty
    Dim strLocation As String

            Set objConnectionProperty = i_objReportTable.ConnectionProperties("Integrated Security")
            objConnectionProperty.Value = True
        'Get the Datasource Property of the Table and set it with the server name
        Set objConnectionProperty = i_objReportTable.ConnectionProperties("Data Source")
        objConnectionProperty.Value = m_strServerName
        'Get the Initial Catalog Property of the Table and set it with the database name
        Set objConnectionProperty = i_objReportTable.ConnectionProperties("Initial Catalog")
        objConnectionProperty.Value = m_strDatabaseName
        Exit Sub

    Accepted Solution

    I have managed to fix this.
    I have used the following code :

    i_objReportTable.ConnectionProperties.Add "Integrated Security", True
    i_objReportTable.ConnectionProperties.Add "Data Source",m_strServerName
    i_objReportTable.ConnectionProperties.Add "Initial Catalog",m_strDatabaseName
    i_objReportTable.ConnectionProperties.Add "Provider","SQLOLEDB"

    Seems to work ok using this method.

    Not too sure why i have to delete and recreate the connection properties for reports that run from a stored procedure.

    Reports that run from SQL tables worked with the previous code.

    LVL 100

    Expert Comment

    NOt sure either unless there is some difference in a connection to an SPP when compared to a view or table.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
    There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now