?
Solved

CRYSTAL REPORT

Posted on 2011-05-12
15
Medium Priority
?
469 Views
Last Modified: 2012-05-11
i get an error,server has not yet been opened

Private Sub Form_Load()

Dim CrApp As CRAXDRT.Application
Dim CrRep As CRAXDRT.Report
Dim oCrystalParameters As CRAXDRT.ParameterFieldDefinitions
Dim CrtParameters As CRAXDRT.ParameterFieldDefinitions
Dim CrtParameter As CRAXDRT.ParameterFieldDefinition

Dim dd As String
dd = "YIOP2795776"

Set CrApp = New CRAXDRT.Application
Set CrRep = CrApp.OpenReport("C:\JSMa.rpt")
 
CrRep.DiscardSavedData
Set CrtParameters = CrRep.ParameterFields

For Each CrtParameter In CrtParameters
  If CrtParameter.Name = "{?@strOrderNo}" Then
       CrtParameter.AddCurrentValue dd
  End If
Next CrtParameter


CRViewer1.ReportSource = CrRep
CRViewer1.ViewReport
Set CrRep = Nothing
Set CrApp = Nothing
End Sub
0
Comment
Question by:AnnaJames77
  • 6
  • 5
  • 2
  • +2
15 Comments
 
LVL 16

Accepted Solution

by:
Kamal Khaleefa earned 500 total points
ID: 35745121
0
 
LVL 4

Expert Comment

by:musalman
ID: 35745225
How are you connecting to Database ,
By OLEDB OR ODBC ?

If ODBC, Make sure you have correct ODBC connection with all user / pwd...


0
 

Author Comment

by:AnnaJames77
ID: 35745349
its oledb
0
Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

 
LVL 4

Expert Comment

by:musalman
ID: 35745391
TRY TO MAKE IT SIMPLE Initially,

Remove Password from Report, and then check,

Try Executing a Very basic Report without any parameter, IT will help you narrow down the problem...

Are you able to Execute normal SQL from your code to Database ?
0
 

Author Comment

by:AnnaJames77
ID: 35745542
yes without passing parameter it executes. Am trying to pass a parameter
0
 

Author Comment

by:AnnaJames77
ID: 35745547
without passing parameter i dont have to use the logontoserver line. It executes with the below code

Private Sub Form_Load()

Dim CrApp As CRAXDRT.Application
Dim CrRep As CRAXDRT.Report
Dim dd As String
dd = "YIOP2795776"

Set CrApp = New CRAXDRT.Application
Set CrRep = CrApp.OpenReport("C:\JSMa.rpt")
 
CRViewer1.ReportSource = CrRep
CRViewer1.ViewReport
Set CrRep = Nothing
Set CrApp = Nothing
End Sub
0
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 500 total points
ID: 35745607
pass a dataset to your report, you will never have any problem: http://emoreau.com/Entries/Articles/2006/09/Feeding-Crystal-Reports-from-your-application.aspx
0
 
LVL 4

Assisted Solution

by:musalman
musalman earned 500 total points
ID: 35745622
Ok Add Following Code before Assigning Report Path using your Variables:

myConnectionInfo.ServerName = ServerName
        myConnectionInfo.DatabaseName = Database
        If CRUserIntegratedSecurity Then
            myConnectionInfo.IntegratedSecurity = True
        Else
            myConnectionInfo.UserID = UserId
            myConnectionInfo.Password = PWD
        End If

Where Variables hold data like :

 ServerName = "Server Name"
 Database = "Database Name"
 UserId = "User ID"
 PWD = "PWD"
0
 

Author Comment

by:AnnaJames77
ID: 35745711
Thanku for your reply. With the below code it excuetes. But it prompts me for the parameter. I have actually passed the parameter to the report. then why does it promt me again. if i use enableprompting=false,  report appears with no value. PLS Help

Private Sub Form_Load()

Dim CRApp As New CRAXDRT.Application
Dim CRReport As New CRAXDRT.Report   'crystal report object
Dim CrtParameters As CRAXDRT.ParameterFieldDefinitions
Dim sRPTFile As String
Dim simula As String
Dim tapos As String
sRPTFile = "C:\JSMa.rpt"
Set CRReport = CRApp.OpenReport(sRPTFile)

    simula = "GTRYR"
  '  tapos = Format(DTPicker2.Value, "YYYY/MM/DD")
   
    With CRReport
        .DiscardSavedData
            .Database.Tables.Item(1).SetLogOnInfo ".", "db", "sa", "sa"
            Set CrtParameters = CRReport.ParameterFields
        .ParameterFields.GetItemByName("@strOrderNo").AddDefaultValue simula

    End With

    'Show Report
    CRViewer1.ReportSource = CRReport
    CRViewer1.EnableExportButton = True
    CRViewer1.DisplayGroupTree = False
    CRViewer1.EnableDrillDown = True
    CRViewer1.EnableDrillDown = False
    CRViewer1.EnableCloseButton = True
    CRViewer1.ViewReport
    CRViewer1.Zoom (100)
    CRViewer1.Visible = True
    CRViewer1.ZOrder 0
End Sub
0
 
LVL 4

Expert Comment

by:musalman
ID: 35746056
Actually there are different ways to execute Report.
I used like :

 Dim RptDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument
 RptDocument.SetParameterValue("JOBNO", Val1)


             
0
 

Author Comment

by:AnnaJames77
ID: 35746068
i'm using vb6 and CR 8.5
0
 
LVL 4

Expert Comment

by:musalman
ID: 35746107
Ohh Sorry ,
I assume Vb.Net...

I dont have exact code so i cant help in this regard more... But I hope you can achieve it as you are close to success,
0
 

Author Comment

by:AnnaJames77
ID: 35746126
Thankyou Musalman for all your replies
0
 
LVL 101

Assisted Solution

by:mlmcc
mlmcc earned 500 total points
ID: 35747733
If after passing the parameter, you get prompted for a value, the value you passed is not valid or you are passing it wrong.

You might use

.ParameterFields.GetItemByName("{?strOrderNo}").AddCurrentValue simula

mlmcc
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 35747793
You could also use

.ParameterFields(1).AddCurrentValue simula

mlmcc
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month13 days, 8 hours left to enroll

749 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