C
Charlie Brown
The following code is what I have been using in .net 1.1 for years.
Now upgrading to .net2.0 and Crystal reports for vs2005, it no longer
works, although as far as i can tell it is still supported. The error
I receive tells me that I did not provide @Location parameter with a
value. Also to note is the database changes at runtime.
'This report uses the PULL method.
Dim crtableLogoninfos As New TableLogOnInfos
Dim crtableLogoninfo As New TableLogOnInfo
Dim crConnectionInfo As New ConnectionInfo
Dim rpt As New
CrystalDecisions.CrystalReports.Engine.ReportDocument
With rpt
.Load(strReportPath & "Schedule.rpt")
.SetParameterValue("@LocationID",
CurrentLocation.LocationID.ToString)
.SetParameterValue("@WorkCenter", WorkCenter)
.SetParameterValue("@StartDate",
StartDate.ToShortDateString)
.SetParameterValue("@EndDate", EndDate.ToShortDateString)
.SetParameterValue("@LocationName", CurrentLocation.Name)
End With
'Set the db logon info
With crConnectionInfo
.ServerName = servername
.DatabaseName = databasename
.UserID = username
.Password = password
End With
'Loop through each table in the report and apply the LogonInfo
information
Dim CrTables As Tables = rpt.Database.Tables
For Each CrTable As Table In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next
'Set the viewer to the report object to be previewed.
CV2.ReportSource = rpt
Now upgrading to .net2.0 and Crystal reports for vs2005, it no longer
works, although as far as i can tell it is still supported. The error
I receive tells me that I did not provide @Location parameter with a
value. Also to note is the database changes at runtime.
'This report uses the PULL method.
Dim crtableLogoninfos As New TableLogOnInfos
Dim crtableLogoninfo As New TableLogOnInfo
Dim crConnectionInfo As New ConnectionInfo
Dim rpt As New
CrystalDecisions.CrystalReports.Engine.ReportDocument
With rpt
.Load(strReportPath & "Schedule.rpt")
.SetParameterValue("@LocationID",
CurrentLocation.LocationID.ToString)
.SetParameterValue("@WorkCenter", WorkCenter)
.SetParameterValue("@StartDate",
StartDate.ToShortDateString)
.SetParameterValue("@EndDate", EndDate.ToShortDateString)
.SetParameterValue("@LocationName", CurrentLocation.Name)
End With
'Set the db logon info
With crConnectionInfo
.ServerName = servername
.DatabaseName = databasename
.UserID = username
.Password = password
End With
'Loop through each table in the report and apply the LogonInfo
information
Dim CrTables As Tables = rpt.Database.Tables
For Each CrTable As Table In CrTables
crtableLogoninfo = CrTable.LogOnInfo
crtableLogoninfo.ConnectionInfo = crConnectionInfo
CrTable.ApplyLogOnInfo(crtableLogoninfo)
Next
'Set the viewer to the report object to be previewed.
CV2.ReportSource = rpt