Crystal Reports in VS 2005

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
 
C

Charlie Brown

Also need to add that if I change the datasource at runtime to the same
one I used to create the report everything runs fine, but when I change
the datasource to point to the production server, i get the error.
 
C

Charlie Brown

I have confimed that this must be a bug in the Crystal Reports for
VS2005. I have reproduced the following several times.

1. Created a report that gets data from a stored procedure having
parameters on sql server

2. create a vb.net project with a crystalreportviewer control

3. bind the report to the control at runtime

4. at runtime, the viewer control will ask the user to input values for
the params

5. report loads as expected

During step 3, if the database location is changed to a different
server than the one used when developing the Crystal Report, the
following will occur.

-->4. at runtime, the viewer control will ask the user to input values
for the params

-->5. report loading fails with an ADO error stating the stored
procedure expected parameters that were not supplied.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top