Solved

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

Posted on 2006-06-29
16
359 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
display only completed quarters in SQL script 4 48
display n/a in column 2 24
Crystal Reports Version 7 4 17
A string is required here error 20 11
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

864 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

23 Experts available now in Live!

Get 1:1 Help Now