I have an app I'm migrating from vb.net 2003 to v2008. I'm using the push model via SetDataSource to attach (bind) datasets from an Access database to a report at runtime. This has been working fine in 2003 code. Now, in v2008, I'm presented with a logon dialog box which fails no matter what I put in it. I found some code which allows me to update the server name for the tables in the ReportDocument object (
LogOnInfo.ConnectionInfo.ServerName), which I refresh by invoking the ApplyLogOnInfo method. This gets me past the logon prompt.
However, now the data that shows on the report is not the data from the datasets, it's the data from the query that was used as the datasource when the report was originally designed. This is not data that was saved with the report, as the report has no saved data.
I've included the code snippet with the relevant section below:
' mDS is a collection of DataSet objects.
' crvViewer is the Crystal Viewer control.
' gDataPath, gReportPath, mReportName are string variables.
' conDataDB is a string constant.
Dim cr As New ReportDocument
Dim i As Integer
Dim r As Integer
cr.Load(gReportPath & mReportName)
For i = 0 To cr.Database.Tables.Count - 1
With cr.Database.Tables(i)
.LogOnInfo.ConnectionInfo.ServerName = gDataPath & conDataDB
.ApplyLogOnInfo(.LogOnInfo)
End With
Next
cr.VerifyDatabase()
cr.Refresh()
If (Not mDS Is Nothing) Then
cr.SetDataSource(mDS(1))
For i = 2 To mDS.Count ' if more than one dataset, for the report's subreports
For r = 0 To (cr.Subreports.Count - 1)
With cr.Subreports(r)
If (mDS(i).Tables(0).TableName = .Database.Tables(0).Name) Then
.SetDataSource(mDS(i))
Exit For
End If
End With
Next
Next
End If
crvViewer.ReportSource = cr
I've tried moving the logon section (in red) to below the section binding the datasets, but it doesn't make a difference.
Thanks,
Dan