Solved

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

Posted on 2006-06-29
16
349 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 69

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 69

Expert Comment

by:Éric Moreau
ID: 17010345
Have you tried the SetParameter value method: http://support.businessobjects.com/library/kbase/articles/c2013539.asp
0
 
LVL 69

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 69

Expert Comment

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

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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 69

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 69

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now