Solved

Crystal Reports 10 app crash when report is previewd 2nd time

Posted on 2008-10-18
13
2,773 Views
Last Modified: 2013-03-30
I made a vb6 app that shows pre disigned reports in Crystal reports 10, i use a form with Crystal report viewer Activx control. it was working fine until a week ago suddenly it start crashing. when i run my app from vb6 IDE the first time, i can see a report and when i want to see a second report or the same again app just crash and VB IDE crash also sometime telling me that vb6.exe stop working and Send this error .... sometimes it give me a memory error right after i click " Dont send" , it says that the memory could not be "read" and the two location it points are always the same e.g 0x032e2110. any idea what im doing wrong ??
0
Comment
Question by:vickyboyy
  • 6
  • 6
13 Comments
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
Has anything changed on the machine?
O/S fixes?

What code are you using to run the application?

When you close the viewer what code runs to cleanup the VB objects?

mlmcc
0
 

Author Comment

by:vickyboyy
Comment Utility
thanks for the reply
nothing changed on my machine only if you consider it a change i change my monitor, on my Win xp pro nothing is changed. no new softwares installed, no service pack nothing, after i have this problem i installed sp6 for vb6, it didnt helped. i made an installer for my app and installed on a machine with win xp pro, there i can not open the form for previewing reports. if i open it the app crash immediatly. on a notebook i installed xp home and sp2 for xp. and then i installed my app and all is working i can see the reports without any problem. one thing more what i saw yesterday was that when i add crystal designer to my app in vb6 and run it then it dont give me any error and no crash....but i make an installer with designer added to my app  and try it on a machine with xp pro ..... same crash occurs...here is my code  ( it was working without any problem till a week ago) ... when i dont add crystal designer then i can view one report. second time i want to view the same report or an other report, Crash with or without memory read error but always with " visual basic encounterd bla bla bla ......"

ReportViewRqs is a Global string type

Private Sub Form_Load()


Dim CrReport As CRAXDRT.Report
Dim appcr As CRAXDRT.Application
Dim coninfo As CRAXDRT.ConnectionProperties
Dim CrxTable As CRAXDRT.DatabaseTable
Dim CrTables As CRAXDRT.DatabaseTables
Dim CrTable As CRAXDRT.DatabaseTable

Me.MousePointer = vbHourglass

Set CrReport = New Report
Set appcr = New Application

Dim rpath As String
Dim password As String
password = "MypassworD"



If ReportViewRqst = "Duo" Then




    rpath = App.Path + "\reports\" + "Duo.rpt"
 

    Set CrReport = appcr.OpenReport(rpath)
   
    For Each CrTable In CrReport.Database.Tables
            CrTable.Location = App.Path + "\Database\FIGHT.mdb"
        Next
   
   

    For Each CrxTable In CrReport.Database.Tables
            CrxTable.SetSessionInfo "", Chr(10) & password
        Next CrxTable
   
 CrReport.RecordSelectionFormula = "{Fightsystem.Fight_ID}=1"
   
   
   
  ElseIf ReportViewRqst = "Fighting" Then




    rpath = App.Path + "\reports\" + "Fighting.rpt"
 

    Set CrReport = appcr.OpenReport(rpath)
   
    For Each CrTable In CrReport.Database.Tables
            CrTable.Location = App.Path + "\Database\FIGHT.mdb"
        Next
   
   

    For Each CrxTable In CrReport.Database.Tables
            CrxTable.SetSessionInfo "", Chr(10) & password
        Next CrxTable
   
 CrReport.RecordSelectionFormula = "{Fightlist.Fightsystemid} = 2 and {Fightlist.Fightid} = 1"
   

 
 
End If
Cr.ReportSource = CrReport




Cr.ViewReport
Me.MousePointer = vbNormal
Set CrReport = Nothing
Set appcr = Nothing
Set coninfo = Nothing
Set CrxTable = Nothing
   

End Sub

hope to see your comment soon while i have to finish this in this week ..Thanks again

0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
You might change the order of the Set to nothing

Set CrxTable = Nothing
Set coninfo = Nothing
Set CrReport = Nothing
Set appcr = Nothing
   
In that way you are working out from the inards of the report.  When you set the report object to nothing you may alsio be deleting the memory pointed to by the connection info and the tables.

mlmcc
0
 

Author Comment

by:vickyboyy
Comment Utility
i was waiting for your answer all the time...
i tried it ... same as before .. crash

is there a simple way to display reports. am i using anything which i really dont need and may be that is the caus of my problem. i dont know much about crystal reports 10.
waiting.......
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 130 total points
Comment Utility
Here is the basic code we used with CR8.  It is similar to yours.  We had our own development network so we set it up to look exactly like the prod with our database server named the same and the shares mapped the same.  In that way we didn't haev to change the tables, the report didn't know anything had changed.  We also used Windows Authentication for database access and the Everyone group had read permissiions as required.

The only thing I see different is we used the viewer.  If your CR object is the viewer then that looks to be the same

mlmcc
Option Explicit

    Private crApp As CRAXDRT.Application

    Private crRpt As CRAXDRT.Report
 

Public Sub crPreview_Report(txtReportName As String, _

                                            txtSelectClause As String)
 

On Error GoTo errHandler
 

'

'   Check if report is already in use

'

    If IsObject(crRpt) Then

       Set crRpt = Nothing

    End If
 

'

'   Open report

'

    Set crApp = New CRAXDRT.Application
 

    Set crRpt = crApp.OpenReport(txtReportName, 1)

    crRpt.RecordSelectionFormula = txtSelectClause
 

'

'   Set flags for CRViewer

'

    crRpt.MorePrintEngineErrorMessages = False

    crRpt.EnableParameterPrompting = False

    crRpt.DiscardSavedData
 
 

'

' Set the viewer's report source to the Report object

'

    Me.rptCRViewer.ReportSource = crRpt

    Me.rptCRViewer.ViewReport

    Me.Show
 

    Exit Sub
 

End

Open in new window

0
 

Author Comment

by:vickyboyy
Comment Utility
hi
i try to do it your way and without any selection formula, just to show the report as it was saved in crystal report 10. it also didnt worked. can you tell me that is there any diffrence between CR 10 and CR XI and which one is supported on Vista. i tried to install my app on vista and it gaved me a dependency error for crviewer.dll ( installed and run as admin). can i use CRXI with vb6. will it bring something good. i mean that can i get rid of this error if i use CR XI

thanks for your help.
Regards
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
CR XI with a service pack is supported on Vista.

If you have CR XI R1 (11.0.xx) then it is SP4
If you have CR XI R2 (11.5.xx) then it is SP2

I don't think CR10 is supported on Vista.

mlmcc
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
You can use CR XI with VB6.  That is the last version that will support VB6.

mlmcc
0
 

Author Comment

by:vickyboyy
Comment Utility
the last thing i want to know. can you give me a link to a good tutorial for CR XI to use with vb6. or any website where i can learn more about CR XI ....
Thank you for your time and help.
0
 

Author Comment

by:vickyboyy
Comment Utility
and To create install package for vista.
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
Unfortunately I can't give you one for use with VB6.

The best I can do is refer you to the references I use which are the complete reference series.

The Complete Reference Crystak Reports nn by Peck

http://www.crystalbook.com/crtcr/program/book/home.asp

mlmcc
0
 

Author Comment

by:vickyboyy
Comment Utility
Hey
I found out what i was doing wrong. i want to share that with you. i found that in CR 10 examples and then i examin your code and there it was also. so what was going wrong. in my code ...


Dim CrReport As CRAXDRT.Report
Dim appcr As CRAXDRT.Application
........
.......

here is the PROBLEM  im setting CrReport as new report butt i have to set it as New CRAXDRT.Report
and the same for .Application ....
and what i was doing wrong ...

Set CrReport = New Report
Set appcr = New Application

i tried it and it workd 100%
Thanks that you took interest in my problem. i will accept your example as solution. afterall you are the only one here who is trying to help me and you did.
CHEERS
0
 

Expert Comment

by:maxcellx
Comment Utility
Thank you ... I tried all the ways to resolve this problem but it's never help
and then I simply define the report  object generaly and  Realy it's working with me very good
thank you guys
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

772 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

9 Experts available now in Live!

Get 1:1 Help Now