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

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,

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

workinclassjoeAuthor Commented:
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?

workinclassjoeAuthor Commented:

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.



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
workinclassjoeAuthor Commented:
Sorry, I'm using EE QuickPost.  I didn't want this question deleted, just closed.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.