Link to home
Create AccountLog in
Avatar of dayiku
dayiku

asked on

How can i refresh report values from the database

I have a vb application that pulls up a crystal report.
I can view the report but for some reason i cannot view updated values from the database.
Can somebody help me on how to refresh the report so that any data added or removed will show up on the prompts for the report.
Below is my code,

    Set Report = Appl.OpenReport("c:\crystal_report.rpt")
    Report.DiscardSavedData

    Report.Database.Tables(1).SetLogOnInfo "machinename", "databasename", "userid", "password"
   
    CRViewer1.DisplayToolbar = True
    CRViewer1.EnableRefreshButton = True

    CRViewer1.ReportSource = Report
    CRViewer1.ViewReport

I am connecting to an oracle database through an odbc connection
   
Avatar of weiroblpay
weiroblpay
Flag of United States of America image

I believe you can get rid of saved data in 2 ways.  One of them you already have done by doing Report.DiscardSavedData
If you have access to the report file itself, and can edit it then you should check the File menu and see if the "Save data with report" menu item is checked. If it is, then uncheck it and save the report. That usually solves it.

If that doesn't work then try the ReadRecords method of the report object like this:
Set Report = Appl.OpenReport("c:\crystal_report.rpt")
    Report.DiscardSavedData

    Report.Database.Tables(1).SetLogOnInfo "machinename", "databasename", "userid", "password"
    Report.ReadRecords

If you still can't get it to work, please let us know which version of Crystal reports your're using.

Good luck,

Ron
Avatar of dayiku
dayiku

ASKER


That did not work.
I opened up the file in Crystal Reports and the "Save data with report" was unchecked"
I then added the Report.ReadRecords to my file but i still get the same values.
I have version 8.5
ASKER CERTIFIED SOLUTION
Avatar of weiroblpay
weiroblpay
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of dayiku

ASKER

Actually it seems to be connecting properly.
Do you have the instructions for connecting to an oracle database?