Solved

What is going on here? It was working and now it fails

Posted on 2006-06-29
16
386 Views
Last Modified: 2008-01-09
Dim mycommand = New SqlClient.SqlCommand("spMdViewClaimdetail", myConnection)
        Dim adapter As New SqlClient.SqlDataAdapter(mycommand)
        Dim ds As New DataSet()
        Dim crpt As New CrystalReport1()
        Dim crpt2 As New CrystalReport2()
        'new
        Dim crParameterfieldDefinitions As ParameterFieldDefinitions
        Dim crParameterfieldDefinition As ParameterFieldDefinition
        Dim crParameterValue As New ParameterValues()
        Dim crparameterdiscreteValue As New ParameterDiscreteValue()

        '  Dim Report As New ViewReports()
        Dim rptCollection As New CrystalDecisions.Shared.ParameterValues()
        Dim pdvClaim As New CrystalDecisions.Shared.ParameterDiscreteValue()
        Dim crvparameter As New CrystalDecisions.Windows.Forms.CrystalReportViewer()
        Try
            If (myConnection.State = ConnectionState.Closed) Then
                myConnection.open()
            End If

            With mycommand
                .CommandTimeout = 1000
                .CommandType = CommandType.StoredProcedure
                .Parameters.Add("@Claimno", SqlDbType.BigInt)
                .Parameters("@Claimno").Value = denial
                .ExecuteNonQuery()
            End With

            adapter.Fill(ds)

            ds.Tables(0).TableName = "spMDViewDenials"
            If ds.Tables(0).Rows(0).Item(9) = "I" Or ds.Tables(0).Rows(0).Item(9) = "IP" Then
                inout = True
                crpt.SetDataSource(ds)
            End If
            If ds.Tables(0).Rows(0).Item(9) = "O" Or ds.Tables(0).Rows(0).Item(9) = "OP" Then
                inout = False
                crpt2.SetDataSource(ds)
            End If


            ' Set the discreet value to the customers name.
            pdvClaim.Value = denial

            'Add it to the parameter collection.
            rptCollection.Add(pdvClaim)

            'Apply the current parameter values.
            If inout = True Then
                crpt.DataDefinition.ParameterFields("@Claimno").ApplyCurrentValues(rptCollection)
            Else
                crpt2.DataDefinition.ParameterFields("@Claimno").ApplyCurrentValues(rptCollection)
            End If
            crpt.DataDefinition.ParameterFields("@Claimno").ApplyCurrentValues(rptCollection)

            'Hide group tree for this report
            crvparameter.DisplayGroupTree = False

            '  Set the report source for the crystal reports viewer to the
            ' report instance.
            If inout = True Then
                crvparameter.ReportSource = crpt
            Else
                crvparameter.ReportSource = crpt2
            End If

            ' new

            'crparameterdiscreteValue.Value = denial
            'crParameterfieldDefinitions = crpt.DataDefinition.ParameterFields
            'crParameterfieldDefinition = crParameterfieldDefinitions.Item("@Claimno")
            'crParameterValue.Clear()
            'crParameterValue.Add(crparameterdiscreteValue)

            'crParameterfieldDefinition.ApplyCurrentValues(crParameterValue)


            ds.Tables(0).TableName = "spMDViewDenials"
            If inout = True Then
                crpt.SetDataSource(ds)
            Else
                crpt2.SetDataSource(ds)
            End If

            Dim viewer As New Viewer()

            'If inout = True Then
            '    viewer.CrystalReportViewer2.ReportSource = crpt
            'Else
            '    viewer.CrystalReportViewer2.ReportSource = crpt2
            'End If
            If now = False Then
                viewer.Show()
            Else
                If inout = True Then
                    crpt.PrintToPrinter(1, False, 0, 0)
                Else
                    crpt2.PrintToPrinter(1, False, 0, 0)
                End If
            End If

            myConnection.Close()
        Catch ex As Exception
            MsgBox("Exception: " & ex.Message & "  " & ex.ToString, MsgBoxStyle.Critical)
        End Try
0
Comment
Question by:Ilianam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 7
  • 2
16 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 17009903
Hi Ilianam,

And the problem/error/exception is ?

Cheers!
0
 

Author Comment

by:Ilianam
ID: 17010296
the error starts here
 If inout = True Then
                crpt.DataDefinition.ParameterFields("@Claimno").ApplyCurrentValues(rptCollection)
            Else
                crpt2.DataDefinition.ParameterFields("@Claimno").ApplyCurrentValues(rptCollection)
            End If

The error says: Invalid Field Name. CrystalDecisions.CrystalReports.Engine.InvalidArgumentException: Invalid field name......
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 17010345
Have you tried the SetParameter value method: http://support.businessobjects.com/library/kbase/articles/c2013539.asp
0
Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

 
LVL 70

Expert Comment

by:Éric Moreau
ID: 17010358
And the $100 question : Are you sure your parameter exist? No typo error?
0
 

Author Comment

by:Ilianam
ID: 17010453
The funny part, is that it was working 100%. I move it to another box and gave me another error
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 17010485
Same version of CR?
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 17010496
Are you sure that you have the latest/correct version of CrystalReport1 and CrystalReport2 ? Do you see the parameter if you open the reports in the designer?
0
 

Author Comment

by:Ilianam
ID: 17010630
checked, now is asking for the database connection......
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 17010685
The designer or the runtime?
0
 

Author Comment

by:Ilianam
ID: 17010756
the runtime
0
 

Author Comment

by:Ilianam
ID: 17010761
also, the famous list of fields on the right has disappeared   :(
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 17011287
You will need to rebind your datasource. I can't help you much on that because I always pass dataset to CR. See http://aspalliance.com/490#Page3
0
 
LVL 42

Expert Comment

by:frodoman
ID: 17012030
Are you using Visual Studio?  If so you want to delete the .rpt file from your VS Project (make a backup copy first).  In your project folder, delete the vb file associated with the report (e.g.: report1.vb).  Now put your backup copy of the .rpt into the folder and add the report to your project.  VS will regenerate the .vb file and your binding should work now.

frodoman
0
 

Author Comment

by:Ilianam
ID: 17013019
Got a new error.
Failed to open a rowset
0
 
LVL 42

Expert Comment

by:frodoman
ID: 17013373
That error typically means that there is an error related to the db.  It looks like you're using a stored procedure so my first guess would be that you aren't passing all of the parameters or perhaps not the right type of parameter values.  Could also be that the values you're passing are causing an error in your proc - you might want to execute it with the same params and make sure it works - also display the param values in your application to make sure you're passing what you think you're passing.

frodoman
0
 

Author Comment

by:Ilianam
ID: 17013560
It's killing me. I fixed the previous issue. Again, I move it to the test box, its requesting the database userid and password
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

634 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question