Skip to Content
0
Former Member
Feb 18, 2009 at 11:32 AM

Changing database at run-time doesn't work

97 Views

Hello there,

I'm using Crystal reports that comes with .NET (1.1). I have created a report thats needs to be able to report off six databases. All the databases are on one server and have identical tables. So I created a stored procedure and saved it in all six databases and the report gets it data from this proc. At run-time the user can select which company (database) they want to report from, but the report is only reporting off the database that I used when i designed the report. I am changing the logon info at run-time to the new database but it just doesn't work. I'm at the end of my tether with this any help will be appreciated.

This is the function that changes the logon info.

Private Function ApplyLogon(ByVal cr As CrystalDecisions.CrystalReports.Engine.ReportDocument, ByVal ci As ConnectionInfo) As Boolean

Dim li As TableLogOnInfo

Dim Db As String

' For each table apply connection info

For Each tbl As CrystalDecisions.CrystalReports.Engine.Table In cr.Database.Tables

li = tbl.LogOnInfo

li.ConnectionInfo = ci

tbl.ApplyLogOnInfo(li)

' Check if logon was successful

If not tbl.TestConnectivity() Then

Return False

End If

Next

Return True

End Function

Thanks.