Link to home
Start Free TrialLog in
Avatar of AnnaJames77
AnnaJames77

asked on

CRYSTAL REPORT

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
ASKER CERTIFIED SOLUTION
Avatar of Kamal Khaleefa
Kamal Khaleefa
Flag of Kuwait image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
How are you connecting to Database ,
By OLEDB OR ODBC ?

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


Avatar of AnnaJames77
AnnaJames77

ASKER

its oledb
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 ?
yes without passing parameter it executes. Am trying to pass a parameter
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
SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Actually there are different ways to execute Report.
I used like :

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


             
i'm using vb6 and CR 8.5
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,
Thankyou Musalman for all your replies
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You could also use

.ParameterFields(1).AddCurrentValue simula

mlmcc