Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Problem adding parameters to crystal report

Posted on 2011-10-12
15
Medium Priority
?
1,026 Views
Last Modified: 2012-05-12
below is the following code I am using to print a report.  If I leave the 3rd parameter(a sub Report parameter) out and the first two parameters in, I get nothing.  If I run the code as shown then I get "Prompting information is missing"  When I run the report in crystal its ask for wo_number put doesnt ask for anything else.  If I look at number of paramters and their names they equal what I have in list.   It says there are 3 of them.  The 3rd parameter is a sub-report parameter that is linked to the wo_number of the main report.

thanks
0
Comment
Question by:mgmhicks
  • 7
  • 7
14 Comments
 

Author Comment

by:mgmhicks
ID: 36958095
sorry here is the code

Protected Function PrintCharges() As Boolean
        Dim rd As New ReportDocument
        Dim rptDS As New DataSet
        Dim rptDS2 As New DataSet
        Dim myCmd As New SqlCommand
        Dim da As New SqlDataAdapter
        ' Dim myConn As String = "SERVER=10.10.10.44,8433;Database=AptGalleryInspections;uid=sa;pwd=sh4207"
        'Dim cn As New SqlConnection(myconn)

        Dim myfilelocation As String = Server.MapPath("../Reports/MOInspectionsResidentWeb.rpt")
        Try
            'Session.Add("oError", myfilelocation)
            'Response.Redirect("..\Errors.aspx")

            rd.Load(myfilelocation)
            '  SetCurrentValuesForParameterField(rd, mWO_Number, mPropertyName)
            rd.SetParameterValue(0, mWO_Number)
            rd.SetParameterValue(1, mPropertyName)
            rd.SetParameterValue("Pm-InspectionMaster.WO_Number", mWO_Number, "InspectionDetails")
            rd.SetDatabaseLogon("sa", "sh4207", "10.10.10.44,8433", "AptGalleryInspections")
            Dim logon As New TableLogOnInfo
            Dim tbl As Table
            Dim subReport As ReportDocument
            For Each subReport In rd.Subreports
                For Each tbl In subReport.Database.Tables
                    logon = tbl.LogOnInfo
                    logon.ConnectionInfo.ServerName = "10.10.10.44,8433"
                    logon.ConnectionInfo.DatabaseName = "AptGalleryInspections"
                    logon.ConnectionInfo.UserID = "sa"
                    logon.ConnectionInfo.Password = "sh4207"
                    tbl.ApplyLogOnInfo(logon)
                Next
            Next
            CR1.ReportSource = rd

        Catch ex As Exception
            Session.Add("oError", ex.Message)
            Server.Transfer("..\Errors.aspx")
        End Try
        ' exports pdf file from crystal reports

        ' theReport.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, False, "ExportedReport")

        
    End Function

Open in new window

0
 
LVL 101

Expert Comment

by:mlmcc
ID: 36958270
Why are you trying to pass a value to this parameter?
Pm-InspectionMaster.WO_Number

That is a parameter used to link the main report to the subreport.  The value is supplied by the report.

mlmcc
0
 

Author Comment

by:mgmhicks
ID: 36958291
ok, I wasnt at first, but I kept getting nothing when I tried to print the report through code.  Use the same wo number in crystal and it works fine.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 101

Expert Comment

by:mlmcc
ID: 36958334
Can you upload the report?

mlmcc
0
 

Author Comment

by:mgmhicks
ID: 36958451
it uses sql database, we you be able to look at it?

I have another report, works on developement machine, but It get it asking for database, user name and password, but the username and password is filled in, and it wont let me add anything to the database field.  I attached what it looks like.  This does use 2 databases, could that be a issue.  Thought I took care of when going through the tables.  Also attached is the code.

10.10.10.44,8433  
Server name:    
Database name:    
User name:    
Password:    
 Use Integrated Security

Open in new window

Protected Function PrintMakeReady() As Boolean
        Dim rd As New ReportDocument
        Dim rptDS As New DataSet
        Dim rptDS2 As New DataSet
        Dim myCmd As New SqlCommand
        Dim da As New SqlDataAdapter
       

        Dim myfilelocation As String = Server.MapPath("../Reports/MakeReadyReportWeb.rpt")
        Try

            rd.Load(myfilelocation)
            rd.SetParameterValue(0, mWO_Number)
            '   rd.SetDatabaseLogon("sa", "sh4207", "10.10.10.44,8433", "AptGalleryInspections")

            'Dim mSelection As String = "{MakeReadyMaster.WO_Number}={?WorkOrderNo} and ({MakeReadyDetails.Condition}<>'Satisfactory' and {MakeReadyDetails.Condition}<>'N/A')"

            ' rd.RecordSelectionFormula = mSelection
            Dim logon As New TableLogOnInfo
            Dim tbl As Table
            For Each tbl In rd.Database.Tables
                If tbl.Name = "Properties" Then
                    logon = tbl.LogOnInfo
                    logon.ConnectionInfo.ServerName = "10.10.10.44,8433"
                    logon.ConnectionInfo.DatabaseName = "TAG_eSite"
                    logon.ConnectionInfo.UserID = "sa"
                    logon.ConnectionInfo.Password = "sh4207"
                    tbl.ApplyLogOnInfo(logon)
                Else
                    logon = tbl.LogOnInfo
                    logon.ConnectionInfo.ServerName = "10.10.10.44,8433"
                    logon.ConnectionInfo.DatabaseName = "AptGalleryInspections"
                    logon.ConnectionInfo.UserID = "sa"
                    logon.ConnectionInfo.Password = "sh4207"
                    tbl.ApplyLogOnInfo(logon)
                End If
            Next

            Dim subReport As ReportDocument
            For Each subReport In rd.Subreports
                For Each tbl In subReport.Database.Tables
                    logon = tbl.LogOnInfo
                    logon.ConnectionInfo.ServerName = "10.10.10.44,8433"
                    logon.ConnectionInfo.DatabaseName = "AptGalleryInspections"
                    logon.ConnectionInfo.UserID = "sa"
                    logon.ConnectionInfo.Password = "sh4207"
                    tbl.ApplyLogOnInfo(logon)
                    
                Next
            Next
            CR1.ReportSource = rd

        Catch ex As Exception
            Session.Add("oError", ex.Message)
            Server.Transfer("..\Errors.aspx")
        End Try
        ' exports pdf file from crystal reports

        ' theReport.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, False, "ExportedReport")


    End Function

Open in new window

0
 
LVL 101

Expert Comment

by:mlmcc
ID: 36958715
Is the second databse for the subreport?
As far as  I know you can't use 2 databases in a report through the SDK unless one is for the main report and the other is for the subreport.

mlmcc
0
 

Author Comment

by:mgmhicks
ID: 36958974
Yes how can I set the database to the subreport.  I'd like to try that.  I thought going through the tables would take care of that.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 36959045
The code you are using should do it.

From the code it looks like the main report uses 2 databases.  I don't think that is support in the SDK

mlmcc
0
 

Author Comment

by:mgmhicks
ID: 36959058
This exact code works fine on my developement machine.  I cant figure it out.  Something is wrong with the path of the report or something.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 36959111
Can you log intothe database with that userid and password?

Is it the same database the dev machine logs into?

mlmcc
0
 

Author Comment

by:mgmhicks
ID: 36959150
Yes, I can.  I  published to the web site from my dev machine and the report works.  They both use the same sql server and username and password.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 36959253
It doesn't make sense.

mlmcc
0
 

Accepted Solution

by:
mgmhicks earned 0 total points
ID: 36979281
mlmcc the problem ended up being the report driver I was using.  When I created the report I used sql native client.  When I tried to run on production machine, I received errors not necessarliy related to the problem.  I switched the report to use oledb and everything works great with out changing any code.

0
 
LVL 101

Expert Comment

by:mlmcc
ID: 37144300
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

564 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