I've made a report in Crystal Report that pulls data from two separate databases. They are both on the same server. When I try to run the report from my VB application, it says the table couldn't be found. I'm pretty sure this error is coming from the second database, because if I remove one database from the report it works fine.
My question is, how do I get VB or Crystal to see the second database?
Rather than connecting to two databases, you can create dataset using two databases inside the application and apply dataset to crystal datasource.
For an Example:
Private Sub btnLoad_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim ds As DataSet = New DataSet()
Dim obj As reports = New reports()
Dim crconnectioninfo As ConnectionInfo = New ConnectionInfo()
Dim crtablelogoninfos As TableLogOnInfos = New TableLogOnInfos()
Dim crtablelogoninfo As TableLogOnInfo = New TableLogOnInfo()
Dim CrTables As Tables
Try
If _report = "ISR" Then
crconnectioninfo.ServerName = AquaInvoice.Properties.Settings.[Default].dsn_name
crconnectioninfo.DatabaseName = AquaInvoice.Properties.Settings.[Default].databaseclient
crconnectioninfo.UserID = AquaInvoice.Properties.Settings.[Default].db_user
crconnectioninfo.Password = AquaInvoice.Properties.Settings.[Default].db_password
'Set report path
Dim AppPath As String = Application.StartupPath & "\Reports\rptInvoiceSummary.rpt"
'load report
reportDocument1.Load(AppPath)
'Retrieve data to Dataset from the database. Here you can access two databases and create one dataset in you Data Layer
ds = obj.InvoiceSearchBox(dtpStart.Value.Date, dtpEnd.Value.Date)
'Set report source
reportDocument1.Database.Tables(0).SetDataSource(ds.Tables(0))
reportDocument1.Database.Tables(1).SetDataSource(ds.Tables(1))
'Set parameter values
reportDocument1.SetParameterValue("Start", dtpStart.Value.Date)
reportDocument1.SetParameterValue("End", dtpEnd.Value.Date)
'set viewer
crvDateRangeReports.ReportSource = reportDocument1
crvDateRangeReports.Refresh()
End If
Catch ex As Exception
Throw New Exception("Report load faild!", ex)
End Try
End Sub
'This code originally c# and converted to vb using online code converter