Changing database doesn't work - .NET and CR10 Solution

Posted on 2006-04-17
Last Modified: 2007-12-19
A while back someone asked a question about changing the database in a Crystal Report (  Apparently, even if you've identified a different database in your data source, the report may still point to the old database due to something needing to be set for 'fully qualified table names'.  The solution given spoke to a work around in VB 6 using the CRAXDRT reference.

I'm using Crystal Reports 10 in VB .NET. My form class has Import references to CrystalDecisions.Shared and CrystalDecisions.CrystalReports.Engine, not CRAXDRT.  I use a ReportDocument object to set the Server and Database names depending on who's using the application.  I'm running into the same problem: even though I point to a different database, the data is returned from the database originally set.

Here's a sample of my code, most of which is pulled from the example given in the ApplyLogOnInfo help text (Visual Studio .NET):

                Dim logOnInfo As New TableLogOnInfo
                Dim connectionInfo As New ConnectionInfo
                For x = 0 To Me.multiReportDocument.Database.Tables.Count - 1
                    ' Get the ConnectionInfo Object.
                    logOnInfo = New TableLogOnInfo
                    logOnInfo = multiReportDocument.Database.Tables.Item(x).LogOnInfo

                    connectionInfo = New ConnectionInfo
                    connectionInfo = multiReportDocument.Database.Tables.Item(x).LogOnInfo.ConnectionInfo

                    ' Set the Connection parameters.
                    If database <> "" Then
                        connectionInfo.DatabaseName = database
                    End If
                    If server <> "" Then
                        connectionInfo.ServerName = server
                    End If
                    If password <> "" Then
                        connectionInfo.Password = password
                    End If
                    If user <> "" Then
                        connectionInfo.UserID = user
                    End If

I only specifiy the database and server names.  I didn't think I needed to set the user and password parms, even though I allow for them for future use, because of Windows Authentication (won't know the password for the individual user's anyway).

Anyone know what I might be missing?  Also, what exactly is the 'Overridden Qualified Table Name' property of the Set Datasource Location window as mentioned in the Q_21516382 document?  I'm using Crystal Reports 10 with a SQLOLEDB Provider connection as well and I have yet to see this property.

Thanks in advance,

Question by:workinclassjoe
    LVL 100

    Expert Comment

    Look at these examples.  I believe there is one that changes the database connection


    Author Comment

    New news:

    This ain't a VB .NET issue at all!

    I just made a duplicate copy of the same report, changed the database in the Set Datasource Location window in the new copy, and ran both the original and the dup stand-alone in Crystal Reports 10.

    Guess what.  They both return the same data, even though the duplicate is pointing to an empty database.  Can someone please tell me what the heck is going on here?

    Thanks for the reference to the samples, mlmcc, but based on this discovery, even with the proper VB code, if the report source malfunctions stand-alone it won't behave any differently in a report viewer.  'Course I've been wrong before.

    Any ideas...anyone?


    Accepted Solution


    Ok, I think I got it.

    As best I can tell, in order to properly change the data source in VB code for a Crystal Report with a SQLOLEDB connection to a SQL Server database, you must acquire access/initialize the connection parameters it uses, not just the ConnectionInfo (if at all necessary).  This can only be done through an instantiated connection control (SQLConnection, OleDBConnection, etc.), where you would change the ConnectionString's "Initial Catalog" and "Integrated Security" parameters.

    I believe that's what the previously mentioned document,, was leading to.  Business Objects has created the COM object CRAXDRT for the very purpose of exposing the parameters of a ConnectionString property for data source initialization (possibly more to it than that; never used this class before).  As far as I can tell, however, it, like it's connection control counterpart, is used to establish a connection and datasource for a dataset or recordset, neither of which I use.  Each report ties directly to a view or stored procedure on my database, so I have no need for a dataset.  Thus, I think the idea of modifying the datasource on the fly is a mute point.

    I'll leave this thread open a while for more feedback should anyone have any.



    Author Comment

    Sorry, I'm using EE QuickPost.  I didn't want this question deleted, just closed.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
    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 …
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    733 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

    19 Experts available now in Live!

    Get 1:1 Help Now