Solved

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

Posted on 2006-06-29
16
368 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
  • 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

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…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

831 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