?
Solved

Refresh Report Data (DiscardSavedData)

Posted on 2003-03-30
10
Medium Priority
?
2,729 Views
Last Modified: 2012-08-14

     Hello!  I'm doing an external crystal report (*.rpt).  Using VB6 as front end and MS Access 2k
as back end.  The database is secured by a password.  The problem I'm having right now is that the reports
are not refreshed.  I've tried using the .DiscardSaveData method but I get an error "cannot open sql server"

Below is my code:
----------------------
With CrystalReport1
              .DataFiles(0) = App.Path & "\MyDB.mdb"
              .ReportFileName = App.Path & "\Reports\rptBoxTypes.rpt"
              .UserName = "Admin"
              .Password = "dbasepass" & Chr(10) & "dbasepass"
              .WindowState = crptMaximized
              .Formulas(0) = "AgentCode='" & gstrAgentCode & "'"
             .SelectionFormula = "{qryPaymentsNBalances.DatePosted} >= #" & FromDate & "# AND {qryPaymentsNBalances.DatePosted} <= #" & _
                                  ToDate & "#"
              .ReportTitle = "Box Types"
              .DiscardSavedData = True
              .Action = 1
End With
----------------------

     How can I make the report refresh it's data?  BTW, am I doing the right way to open a crystal report?
Or there are better ways?  If I'll change my back end to SQL would this code still works?


     I'm now in great trouble.  All the while I thought I was really opening the database and getting the data there but in fact I wasn't I was just opening the report and no database connection was made :(  That's why I'm not getting fresh data.  The code I've been using is not working :(  Any ideas on how would I connect to the data source (Access 2k and passworded)?  I'm doing an external crystal report file and I'm not using the crystal report viewer but instead I'm using the Crystal Report Application component.

Thanks,

enzo c",)

0
Comment
Question by:enzoy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 8235934
Try this

Open the report in CR
Click FILE
Ensure SAVE DATA WITH REPORT is not checked.

Try your report.

What references are you using for Crystal?

Similar code will work with SQL.

mlmcc

0
 

Author Comment

by:enzoy
ID: 8235984
>>Open the report in CR
>>Click FILE
>>Ensure SAVE DATA WITH REPORT is not checked.
I've tried unchecking SAve DAta with Report.  It still won't work.  I found out that I have a wrong database path.  But now I have corrected the database path.  But there's a new error that came up "Error created by database dll".  It seems that I can't connect to the database.

>>>Similar code will work with SQL
If it will be the same, then where would I have to put the login info for the sql server?

thanks,

enzo
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 750 total points
ID: 8236004
"Error created by database dll".  
Usually indicates you are missing some required CR dlls.

What references are you using for Crystal?


Runtime files for CR8

http://support.crystaldecisions.com/library/kbase/articles/c2008238.asp

Error detected
http://support.crystaldecisions.com/communityCS/TechnicalPapers/cr_error_detected_by_db_dll.pdf.asp

mlmcc
0
Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

 

Author Comment

by:enzoy
ID: 8236252
I made it work by setting the data source of the report to "Database files".  Before the data source of the report is set to "More Data Sources > OLE DB".

So the code I'm using are for reports that uses "Database files" as data source.  How about if I'm gonna use OLE DB what would be code?  Specially if my back end would be an SQL server how would that be possible be?

thanks,

enzo
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 8236288
Here is the code I use to run reports from an MS SQL database.

Option Explicit
    Dim crApp As CRAXDRT.Application
    Dim crRpt As CRAXDRT.Report

Public Sub crPreview_Report( )
'
'   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("FULL REPORT PATH", 1)
   
    crRpt.RecordSelectionFormula = "{TableName.DepartmentID} = "


'
'   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

End Sub

Public Sub crPrint_Report( )

'
'   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("FULL REPORT PATH", 1)
   
        crRpt.RecordSelectionFormula = "{TableName.DepartmentID} = "


'
'   Set flags for CRViewer
'
        crRpt.MorePrintEngineErrorMessages = False
        crRpt.EnableParameterPrompting = False
        crRpt.DiscardSavedData

'
'   Print Report
'
       crRpt.PrintOut False
       Unload Me

End Sub


We use integrated security so there is no need for a separate logon to the database.  Add the CR Designer Runtime Library as a reference and the CRViewer as a component.  This code goes on the form with the CRViewer.

mlmcc
0
 

Author Comment

by:enzoy
ID: 8236346
I made it work by setting the data source of the report to "Database files".  Before the data source of the report is set to "More Data Sources > OLE DB".

So the code I'm using are for reports that uses "Database files" as data source.  How about if I'm gonna use OLE DB what would be code?  Specially if my back end would be an SQL server how would that be possible be?

thanks,

enzo
0
 

Author Comment

by:enzoy
ID: 8242803
thanks for single handedly helping me out, although you didnt have help me directly but through the link you gave me I somehow got the idea may be there's a driver issue on my problem and also thanks for the sample code ;) 250 pts for you ;)
0
 

Author Comment

by:enzoy
ID: 8242896
Another thing mlmcc if you would be so kind enough just a simple one.  Which way is best to use my code(using crystal report application component) or your code (using crviewer and CR Designer Runtime Library)  What are the PROs and CONs?

Thanks,

enzo
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 8243335
I don't really know.  I took my code from a reference book I use alot and from this web site.  The reference is
The Complete Reference Crystal Reports by george Peck.

I find my code simple and easy to use.  It is also flexible and can be adapted to most situations.

The methodolgies are very similar.  Since our database uses integrated security i don't need to pass logon information.  I'd have to look into yours more fully to make a complete judgement.

The way I look at it is, use the code you understand that does the job.

mlmcc
0
 

Author Comment

by:enzoy
ID: 8243460
oh ok thanks for your tips!

thanks,

enzo
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

770 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