Crystal report data not refreshing
Crystal report data not refreshing
Crystal report data not refreshing
Crystal report data not refreshing
Crystal report data not refreshing
Crystal report data not refreshing Crystal report data not refreshing Crystal report data not refreshing Crystal report data not refreshing Crystal report data not refreshing Crystal report data not refreshing Crystal report data not refreshing Crystal report data not refreshing
Crystal report data not refreshing Crystal report data not refreshing
Crystal report data not refreshing
Go Back  Xtreme Visual Basic Talk > > > Crystal report data not refreshing


Reply
 
Thread Tools Display Modes
  #1  
Old 12-17-2003, 08:57 PM
kbrochu kbrochu is offline
Newcomer
 
Join Date: Oct 2003
Posts: 2
Default Crystal report data not refreshing


Hello,
I am trying to write a VB 5.0 program with Crystal 8.5 that looks at Oracle 8.05 data. I would like for the report to use a new recordset as data, rather than the original recordset that was used when the report was created. The following code runs, but continues to return the same data as when the report was created. Your help is much appreciated...here is the code.




Dim appl As New CRAXDRT.Application
Dim rep As New CRAXDRT.Report
Dim AdoRs As New ADODB.Recordset



AdoRs.Open "Select subjects.* from subjects where jid = " & 30, "Driver={Oracle ODBC Driver};" & _
"Dbq=Name;" & _
"Uid=User;" & _
"Pwd=PSW"
Set rep = appl.OpenReport("d:\ivrs\crystalreports\subjects2.rpt", 1)


rep.Database.SetDataSource AdoRs
rep.ExportOptions.DiskFileName = "c:\TestExport15.doc"
rep.ExportOptions.DestinationType = crEDTDiskFile 'or use crEDTDiskFile
rep.ExportOptions.FormatType = crEFTWordForWindows 'format changes for .rft, word, PDF, etc
rep.Export False
rep.SaveAs "d:\ivrs\crystalreports\subjects15.rpt", cr80FileFormat

AdoRs.Close
Set AdoRs = Nothing
Set rep = Nothing
Set appl = Nothing
End Sub
Reply With Quote
  #2  
Old 12-17-2003, 09:26 PM
bvmantos bvmantos is offline
Junior Contributor
 
Join Date: Dec 2003
Location: Philippines
Posts: 202
Default

You may try to set discarddata property to True before passing the recordset to it. maybe it would solve it.
__________________
Bernie
Analyzing the design at my desk...
Reply With Quote
  #3  
Old 12-17-2003, 10:54 PM
mikechan8888 mikechan8888 is offline
Contributor
 
Join Date: Jul 2003
Location: HK
Posts: 436
Default

Quote:
Originally Posted by bvmantos
You may try to set discarddata property to True before passing the recordset to it. maybe it would solve it.


You mean the .DiscardSavedData method?

Mike
Reply With Quote
  #4  
Old 12-17-2003, 11:06 PM
bvmantos bvmantos is offline
Junior Contributor
 
Join Date: Dec 2003
Location: Philippines
Posts: 202
Default

Yes! im not sure though. BUt maybe it would reset the data. Well, i seldom use that method since my report works so fine.
__________________
Bernie
Analyzing the design at my desk...
Reply With Quote
  #5  
Old 12-18-2003, 02:46 AM
mikechan8888 mikechan8888 is offline
Contributor
 
Join Date: Jul 2003
Location: HK
Posts: 436
Default

Quote:
Originally Posted by bvmantos
Yes! im not sure though. BUt maybe it would reset the data. Well, i seldom use that method since my report works so fine.


I understand! I rarely need to use the DiscardSavedData method. But I did experience a couple times when I couldn't get the current data from my report and I followed exactly the same practice I always used. Then I emailed CR support for help and they told me to use this method. It worked after that.

All they told me was "you should always call this method before you call other methods or set other properties."...but as to why...nobody told me...yet...

It still seems to me as a "random error" (but I am sure it is not), but just for safety, I always use this method now...

Mike
Reply With Quote
  #6  
Old 12-18-2003, 06:39 AM
MKoslof's Avatar
MKoslofCrystal report data not refreshing MKoslof is offline
Cum Grano Salis

Retired Moderator
* Guru *
 
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
Default

*typically* .rpt files natively save data with the report..sometimes even when you uncheck the "save data with report" on the rpt file itself. The DisgardSavedData method was built to help clean out existing recordsets.

This method typically does the job, but another neat trick is to create a new report object and initially set it to nothing and then rebuild it..this forces an initial clean build....
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown
Reply With Quote
  #7  
Old 12-18-2003, 07:50 AM
Optikal's Avatar
OptikalCrystal report data not refreshing Optikal is offline
Codeaholic

Retired Leader
* Guru *
 
Join Date: Oct 2002
Location: Winnipeg, MB, Canada
Posts: 4,543
Default

The method I use, is instead of creating a report with data, I just give it a .ttx file which specifies the structure of the recordset (but not actual data). Then I just pass it a recordset which matches the ttx file at runtime. Never have I had to use .DiscardSavedData.
__________________
There are 10 types of people in this world, those that understand binary, and those that don't.
Reply With Quote
  #8  
Old 12-18-2003, 07:57 AM
kbrochu kbrochu is offline
Newcomer
 
Join Date: Oct 2003
Posts: 2
Default

When I add rep.DiscardSavedData to the code, I now get the error:
"Server has not yet been opened"....
Reply With Quote
  #9  
Old 12-18-2003, 10:22 PM
bvmantos bvmantos is offline
Junior Contributor
 
Join Date: Dec 2003
Location: Philippines
Posts: 202
Default

Quote:
Originally Posted by kbrochu
When I add rep.DiscardSavedData to the code, I now get the error:
"Server has not yet been opened"....

Where did u put this line? You should put this code after OpenReport method.
__________________
Bernie
Analyzing the design at my desk...
Reply With Quote
  #10  
Old 12-19-2003, 06:17 AM
MKoslof's Avatar
MKoslofCrystal report data not refreshing MKoslof is offline
Cum Grano Salis

Retired Moderator
* Guru *
 
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
Default

you mentioned earlier that this error has occured randomly before, "Server not yet opened" is a connection issue...really has nothing to do with the .disgarddata method.

For ODBC you should use the setlogonInfo method of th method of the Report.Database.Tables method call. Use a For loop and loop all the tables within the report and connect:

These are all found within the CRAXDRT object: the references are available within your VB project file

Code:
For each crxTable in myReport.Database.Tables crxTable.setlogoninfo serverName, dbName, dbUser, dbPassword Next

I say this because it appears you are using ADO (with the SetDatasource method) and an ODBC connection. Some people say for native connections, to use the logonserver method, but I have never been a fan of it. I tend to always use the Active Data driver for all my CR Reporting.

And yes, you should put the disgardsavedData call after opening your report and binding your connection.
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown
Reply With Quote
  #11  
Old 12-19-2003, 07:45 AM
AndyJ AndyJ is offline
Newcomer
 
Join Date: Dec 2003
Location: Nottingham, UK
Posts: 18
Default This might help...but might not.

Hi,

Sometimes I use a local database as a sort of dataholder for the report whilst I design it. I create an Access DB with tables I need. Then I go into Crystal, set the datasource to my local database - not various other DBs the data actually comes from and setup my report.

Each report has a database. This database is made of tables. Each table has a location. You can chop and change the location of these tables programatically in VB b4 the report is opened.

The following code alters the locations of 2 tables. Table(1) I want to look at a secure Access database, so I set the connectionbufferstring segments to various variables I have (like database location, username, password and securityfilelocation). I then test the connectivity of that table.

The second table to be modifed will be populated with a recordset that I've got open already called mrsSource - note the setprivatedata. Also note that the recordset must be the same structure as the one used when creating the report. Thats why I sometimes make an access DB to simulate what structures the report will be given at runtime (mrsSource is just a query at runtime, but when the report was written I created a table to mimik the recrodset).

Code:
rptCurrent.Database.Tables(1).ConnectBufferString = _ "Database Name=" & gSettings.DatabaseFile & ";;" & _ "Database Type=Access;;" & _ "Database Password=;;" & _ "Session UserID=" & gsUsername & ";;" & _ "Session Password=" & gsPassword & ";;" & _ "System Database Path=" & gSettings.SecurityFile If Not rptCurrent.Database.Tables(1).TestConnectivity Then Err.Raise 1, , "Unable to connect to " & rptCurrent.Database.Tables(1).Name & _ " for " & gsUsername & "." & vbCrLf & vbCrLf End If 'Next iCount rptCurrent.Database.Tables(3).SetPrivateData 3, mrsSource

Hope some of that helps.

Good luck,
Andy

Quote:
Originally Posted by kbrochu
Hello,
I am trying to write a VB 5.0 program with Crystal 8.5 that looks at Oracle 8.05 data. I would like for the report to use a new recordset as data, rather than the original recordset that was used when the report was created. The following code runs, but continues to return the same data as when the report was created. Your help is much appreciated...here is the code.




Dim appl As New CRAXDRT.Application
Dim rep As New CRAXDRT.Report
Dim AdoRs As New ADODB.Recordset



AdoRs.Open "Select subjects.* from subjects where jid = " & 30, "Driver={Oracle ODBC Driver};" & _
"Dbq=Name;" & _
"Uid=User;" & _
"Pwd=PSW"
Set rep = appl.OpenReport("d:\ivrs\crystalreports\subjects2.rpt", 1)


rep.Database.SetDataSource AdoRs
rep.ExportOptions.DiskFileName = "c:\TestExport15.doc"
rep.ExportOptions.DestinationType = crEDTDiskFile 'or use crEDTDiskFile
rep.ExportOptions.FormatType = crEFTWordForWindows 'format changes for .rft, word, PDF, etc
rep.Export False
rep.SaveAs "d:\ivrs\crystalreports\subjects15.rpt", cr80FileFormat

AdoRs.Close
Set AdoRs = Nothing
Set rep = Nothing
Set appl = Nothing
End Sub

Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying (Grouping )the data sorted in a single Crystal Report dpdsouza Database and Reporting 2 06-25-2003 10:52 PM
All data not displaying in Crystal Report jigsaw1975 General 0 06-05-2003 08:48 AM
Refresh data from Crystal Reports report Nicole De Wel Database and Reporting 2 12-05-2002 07:53 PM
Crystal Report vs Data Report astonmak Database and Reporting 0 11-12-2002 09:59 PM
Refreshing a Crystal report ?!? Flimbo Database and Reporting 11 10-05-2002 02:31 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Crystal report data not refreshing
Crystal report data not refreshing
Crystal report data not refreshing Crystal report data not refreshing
Crystal report data not refreshing
Crystal report data not refreshing
Crystal report data not refreshing Crystal report data not refreshing Crystal report data not refreshing Crystal report data not refreshing Crystal report data not refreshing Crystal report data not refreshing Crystal report data not refreshing
Crystal report data not refreshing
Crystal report data not refreshing
 
Crystal report data not refreshing
Crystal report data not refreshing
 
-->