?
Solved

How to use Crystal Reports RAS Server in vb code

Posted on 2007-07-30
14
Medium Priority
?
317 Views
Last Modified: 2013-12-26
I have crystal reports RAS Server version10.  We got that from the company that we use for our main office software.   So we are running a RAS Server.  What do I need to do in vb code, to use the RAS server.  The RAS is looking for a certain locaton for the main office reports, can I also send it a new locatoin for the new reports I would like to use it for?
0
Comment
Question by:mgmhicks
  • 7
  • 7
14 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 19634630
0
 

Author Comment

by:mgmhicks
ID: 19927993
Ok I have set some things up based on the info you sent me.  I have a Reportdocument that was created dragging my report to the form, from my RAS Server.  The problem is I need to send it a SQL parameter as well as 5 report parameters.  When I run the page now, which is basically just opening that report I have to put my password in the get to the server.  So I need to be able to set that so it does  aks the users, and then it comes back and ask for the parameter fields.  How can I set this up.  This page is basically going to load receiving parameters from the called from page and print the report.  Here is what I have tried thus far.

Try
            ReportDocument1.Database.Tables(0).LogOnInfo.ConnectionInfo.Password = "XXXXXX"

            'For i = 0 To ReportDocument1.DataDefinition.ParameterFields.Count - 1
            '    ListBox1.Items.Add(ReportDocument1.DataDefinition.ParameterFields.Item(i).Name)
            'Next

            Exit Sub

            Dim newValue As New CrystalDecisions.Shared.ParameterDiscreteValue
            newValue.Value = "SO00009982"
            Dim paramfieldValues As New CrystalDecisions.Shared.ParameterValues
            'ReportDocument1.DataDefinition.ParameterFields.Item(0).CurrentValues()
            paramfieldValues.Add(newValue)
            ReportDocument1.DataDefinition.ParameterFields.Item(0).ApplyCurrentValues(paramfieldValues)

            'ReportDocument1.Database. = ("SO00009882")
            ReportDocument1.SetParameterValue(0, "SO00009982")
            ReportDocument1.SetParameterValue(1, "SO641")
            ReportDocument1.SetParameterValue(2, "Scott Hicks")
            ReportDocument1.SetParameterValue(3, "")
            ReportDocument1.SetParameterValue(4, "")
            'ReportDocument1.SetParameterValue(5, "SO00009982")

        Catch ex As Exception

        End Try
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 19928653
I am not clear on what further help you need.  DO you want the user prompted for server access?

mlmcc
0
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.

 

Author Comment

by:mgmhicks
ID: 19928683
NO the problem is the user is being prompted for password, everything else is filled in, then after that its asks for all the parameter values, then it errors out.   I am not doing something correctly, cause I cant get it not to ask for username and password.  Actually everything is filled in except password when it asks on the screen.  
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 1500 total points
ID: 19928814
Look at these samples.  One of them shows how to pass the logon information

VB.Net for web application
http://support.businessobjects.com/communityCS/FilesAndUpdates/vbnet_web_samples.exe.asp

VB.Net for windows application
http://support.businessobjects.com/communityCS/FilesAndUpdates/vbnet_win_samples.exe.asp

mlmcc
0
 

Author Comment

by:mgmhicks
ID: 19929886
Ok, I have the report not asking for sql information.  I looked over your links of samples and just am not getting the parameters thiing.  I have 2 to 3 variables that I have to send the report (1 is a sql procedure and the others are crystal parameters).  Could you send me a example in code that I can understand.  This will close 2 calls with you.  Thanks again for the help.
0
 

Author Comment

by:mgmhicks
ID: 19930375
I have this code to setup parameters.  But getting object not set to instance of the object on the
reportdocument1 line.  Any Ideas.

Dim newValue As New ParameterDiscreteValue
        newValue.Value = "SO0008892"
        Dim paramfieldValues As New CrystalDecisions.Shared.ParameterValues
'        ReportDocument1.DataDefinition.ParameterFields.Item(0).CurrentValues()
        paramfieldValues.Add(newValue)
        ReportDocument1.DataDefinition.ParameterFields.Item(0).ApplyCurrentValues(paramfieldValues)
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 19930893
How is ReportDocument1 declared?

Where is it initialized?

mlmcc
0
 

Author Comment

by:mgmhicks
ID: 19930919
It was initialized by dragging the report from the enterprise service to the form.  It created it then.  
0
 

Author Comment

by:mgmhicks
ID: 19935032
Here is the code I am running.  Has 1 report parameter.   What follows is the error I receive when I run it.  I am getting desperate to solve this.

START OF CODE =======================================================

 Private Function PrintReport() As Boolean
        Dim mstr As String
        Dim myParaFields As New ParameterFields
        Dim myParaField As New ParameterField
        Dim myDiscreteValue As New ParameterDiscreteValue
        Dim myParaValue As ParameterValue

        myParaField.ParameterFieldName = "@String"
        myDiscreteValue.Value = "A"
        myParaValue = myDiscreteValue

        myParaField.CurrentValues.Add(myParaValue)
        myParaFields.Add(myParaField)

        crRD1 = New ReportDocument
        crDiskfileLocation = New DiskFileDestinationOptions
        crRD1.Load("d:\mgmweb\test.rpt")

        crRD1.DataDefinition.ParameterFields(0).ApplyCurrentValues(myParaValue)
        Fname = "d:\mgmweb\" & Session.SessionID.ToString & ".pdf"
        crDiskfileLocation.DiskFileName = Fname
        crExportOptions = crRD1.ExportOptions
        With crExportOptions
            .DestinationOptions = crDiskfileLocation
            .ExportDestinationType = ExportDestinationType.DiskFile
            .ExportFormatType = ExportFormatType.PortableDocFormat
        End With
        crRD1.Export()
        Response.ClearContent()
        Response.ClearHeaders()
        Response.ContentType = "application/pdf"
        Response.Write(Fname)
        Response.Flush()
        Response.Close()

    End Function

START OF ERROR ========================================================


Server Error in '/PProLedger' Application.
--------------------------------------------------------------------------------

Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Specified cast is not valid.

Source Error:


Line 49:         crRD1.Load("d:\mgmweb\test.rpt")
Line 50:
Line 51:         crRD1.DataDefinition.ParameterFields(0).ApplyCurrentValues(myParaValue)
Line 52:         Fname = "d:\mgmweb\" & Session.SessionID.ToString & ".pdf"
Line 53:         crDiskfileLocation.DiskFileName = Fname
 

Source File: C:\Documents and Settings\Administrator\VSWebCache\www.theapartmentgallery.com\PProLedger\CRReports.aspx.vb    Line: 51

Stack Trace:


[InvalidCastException: Specified cast is not valid.]
   PProLedger.CRReports.PrintReport() in C:\Documents and Settings\Administrator\VSWebCache\www.theapartmentgallery.com\PProLedger\CRReports.aspx.vb:51
   PProLedger.CRReports.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\Administrator\VSWebCache\www.theapartmentgallery.com\PProLedger\CRReports.aspx.vb:31
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +35
   System.Web.UI.Page.ProcessRequestMain() +750

 

0
 
LVL 101

Expert Comment

by:mlmcc
ID: 19935523
Try using a 1 instead of 0.  Crystal arrays are 1 based.

mlmcc
0
 

Author Comment

by:mgmhicks
ID: 19936260
that gave me the invalid index.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 19936994
Maybe change this line

 myDiscreteValue.Value = "A"


to

 myDiscreteValue.Value = "'A'"

mlmcc
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 19938947
Glad i could help

mlmcc
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month14 days, left to enroll

807 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