cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with refreshing crystalreport 2010, shows the same data

Former Member
0 Kudos

Hi

I am having a problem with refreshing a crystalreport version 2010 used in visualstudio 2010

I created a DLL where a pass some values and in dll i create the objecto ReportDocument

I load the report and pass it a query to load new data but it shows the old data, the report is saved with Save data to report unchecked.

What's wrong, why report doesn't load new data?

there is part of my code that use

Private ReporteCR As New CrystalDecisions.CrystalReports.Engine.ReportDocument

ReporteCR.Load(PathReporte)

ReporteCR.Refresh()

odt = Serv.TraerDataTable(strsql)

' solo necesita user/pwd para evitar ventana de logon

ReporteCR.SetDatabaseLogon(sUsuario, sPwd) ' , sServidor, sBD

' ''Dim savedata As Boolean

' ''savedata = ReporteCR.ReportOptions.EnableSaveDataWithReport

ReporteCR.ReportOptions.EnableSaveDataWithReport = False

ReporteCR.ReportOptions.EnableUseDummyData = False

' '' '' '' ''ReporteCR.ReportOptions.EnableSaveSummariesWithReport = False

' ''If savedata = False And ReporteCR.HasSavedData = True Then

' '' ReporteCR.Refresh()

' '' ReporteCR.VerifyDatabase()

' ''End If

' ''ReporteCR.VerifyDatabase()

' Pasa los datos al reporte

ReporteCR.SetDataSource(odt)

' Asigna objeto crystal a reportviewer

CrystalReportViewer1.ReportSource = ReporteCR

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hello,

After you set location the do a refresh just before the viewer.

Are you hitting the Viewers Refresh button?

Don

Former Member
0 Kudos

Hi Don

yes i'm hiting both reportdocument and CyrtalReportViewver buttons, but it isn't work

former_member183750
Active Contributor
0 Kudos

The code looks pretty messed up to me;

You load the report, then you refresh it then you log it on to the database, then you pass it a dataset(?) or something... E.g.;

You are logging on to the database:

ReporteCR.SetDatabaseLogon(sUsuario, sPwd) ' , sServidor, sBD

Then you are passing what appears to be an ADO .NET dataset to the report:

ReporteCR.SetDataSource(odt)

Do, one or the other. If you want to pass a dataset to the report, you do not need to logon to the database. If you want to use data from the database directly, don't pass in a dataset.

I assume that you want to do the former, thus comment out the following:

ReporteCR.SetDatabaseLogon(sUsuario, sPwd) ' , sServidor, sBD

If that causes issues, see the blog [Troubleshooting Issues with VS .NET Datasets and Crystal Reports|https://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/13270

All I said above is predicated on the assumption that "odt" is an ADO .NET Dataset(?). That being the case, the general code flow should be:

Create dataset

Load report

Pass dataset to report

View report

Ludek

Follow us on Twitter http://twitter.com/SAPCRNetSup

Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]

Former Member
0 Kudos

Hi Ludek

I'm using a datatable object to pass info to the report.

The report has a ODBC conection made in design time

if i don't use setdatabaselogon , it ask me for password for logon

in fact i wrote a dll proyect for show crystalreport, just pass some properties, a sql query string and in the dll opens the crystalreportviewer for show resuls, within dll i uses a access data dll (methods TraerDatatable/TraerDAtaset for retrieve data)

the main problem is that crystalreport doesn't show updated data and i don't know why?

former_member183750
Active Contributor
0 Kudos

Ok. Your code should be as follows:



Private ReporteCR As New CrystalDecisions.CrystalReports.Engine.ReportDocument

ReporteCR.Load(PathReporte)

odt = Serv.TraerDataTable(strsql)

ReporteCR.SetDataSource(odt)

CrystalReportViewer1.ReportSource = ReporteCR

If that results in a db logon, it's because the structure of the odt object is not what the report is expecting. E.g.; the schema is different. You can check this out by writing out the odt object into an XML file. Then open the report in the CR designer. Point the report at the xml and see what happens now. My guess is that you will get a field mapping dialog, indicating that there is something in the xml / odt object that the report does not understand.

- Ludek

Former Member
0 Kudos

ok thanks Ludek i'll check it

thanks for your help

Answers (1)

Answers (1)

saurabh_pathak
Active Contributor
0 Kudos

It looks like you are using DataTable and setting the DataSource to use the datatable.

The datatable access the data stored in-memory cache of data retrieved from a data source.

Even if you try to refresh the the crystal report it's going the bring the same that that has been brought by Datatable/DataSet earlier.

This could be a good read:

http://msdn.microsoft.com/en-us/library/system.data.dataset(v=vs.71).aspx

- Saurabh